Web driver script
Hasan from Trainline shared with us Selenium WebDriver script.
I was using Selenium before Web Driver came into the picture. Need to try this out.
using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
namespace WebDriver
{
[TestFixture]
class TrainlineTest
{
[Test]
public void webDriverTest()
{
var ieCapabilities = DesiredCapabilities.InternetExplorer();
ieCapabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);
var driver = new InternetExplorerDriver(ieCapabilities);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl("http://buytickets.thetrainline.tw.testttl.com");
driver.FindElement(By.Id("OriginStation")).SendKeys("London");
driver.FindElement(By.Id("DestinationStation")).SendKeys("Manchester");
driver.FindElement(By.Id("SingleJourneyCheckBox")).Click();
new SelectElement(driver.FindElement(By.Id("AdultsTravelling"))).SelectByText("2");
IWebElement query = driver.FindElement(By.Id("outwardDate"));
query.SendKeys(Keys.Control + "a");
query.SendKeys("23/02/2012");
driver.FindElement(By.Name("extendedSearch")).Click();
Assert.IsTrue(driver.FindElement(By.Id("showTicketsIdButton")).Displayed, "Show Prices Button Not Present");
}
}
}
Thanks for this coding. Great Work done!!
ReplyDeleteticket-booking
Thanks Master. :)
ReplyDelete