//private static ISelenium selenium; public static void setup() { IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),DesiredCapabilities.HtmlUnit()); //driver = new FirefoxDriver(); Selenium.WebDriverBackedSelenium s = new Selenium.WebDriverBackedSelenium(driver, @"http://site4.way2sms.com/content/index.html"); s.Start(); driver.Navigate().GoToUrl("http://site4.way2sms.com/content/index.html"); WaitForLinkTextPresent(driver, "► click here to go to way2sms.com", 40); driver.FindElement(By.Id("username")).SendKeys("9916089888"); driver.FindElement(By.Id("password")).SendKeys("suprwolf"); driver.FindElement(By.Id("button")).Click(); if (WaitIdPresent(driver, "quickclose1",40000)) { driver.FindElement(By.Id("quickclose1")).Click(); } driver.FindElement(By.Id("quicksms")).Click(); driver.SwitchTo().Frame("frame"); s.WaitForPageToLoad("30000"); driver.FindElement(By.Id("MobNo")).SendKeys("9916089888"); WaitIdPresent(driver, "textArea", 400); driver.FindElement(By.Id("textArea")).SendKeys("test"); driver.FindElement(By.Id("Send")).Submit(); driver.FindElement(By.LinkText("Logout")).Clear(); }
public static IWebDriver Authenticate() { string email = "admin@test"; IWebDriver webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome()); //webDriver.Manage().Window.Maximize(); webDriver.Navigate().GoToUrl("http://dev.icms/Account/Login"); //Enter email address on login page IWebElement emailLogin = webDriver.FindElement(By.Id("Email")); emailLogin.Clear(); emailLogin.SendKeys(email); IWebElement authenticateButton = webDriver.FindElement(By.Id("requestauth")); authenticateButton.Click(); //this should have sent me an email //Let's pretend we got the email and check the server for the authtoken and plug it into the URL string token = HttpUtility.UrlEncode(TestUtilities.AuthenticationUtil.GetAuthToken(email)); string goToUrl = string.Format("http://dev.icms/account/authorize/?authtoken={0}&email={1}&returnUrl=%2f", token, email); webDriver.Quit(); webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome()); webDriver.Navigate().GoToUrl(goToUrl); //Check DOM to see if we are logged in IWebElement elem = webDriver.FindElement(By.CssSelector("h1")); //webDriver.Quit(); if (elem.Text == "Welcome Admin Development") { return webDriver; } return null; }
public void MyTestInitialize() { verificationErrors = new StringBuilder(); DesiredCapabilities capability = DesiredCapabilities.Firefox(); driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20)); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(50)); driver.Manage().Window.Maximize(); driver.Navigate(); }
public void Run(string webProjectFolder, int portNumber) { var webApplication = new WebApplication(ProjectLocation.FromFolder(webProjectFolder), portNumber); _webServer = new IisExpressWebServer(webApplication); _webServer.Start(); _webDriver = new FirefoxDriver(); _webDriver.Navigate().GoToUrl(_webServer.BaseUrl); AppDomain.CurrentDomain.DomainUnload += CurrentDomainDomainUnload; }
public void FindPrice() { IWebDriver driver_ = new RemoteWebDriver(new Uri("http://192.168.1.4:4444/wd/hub"), DesiredCapabilities.Firefox()); driver_.Navigate().GoToUrl("http://www.momoshop.com.tw"); driver_.FindElement(By.CssSelector("#keyword")).SendKeys(this.SearchKeyWord_); driver_.FindElement(By.CssSelector(".inputbtn")).Click(); Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>> info = new Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>>(); try { if (driver_.FindElements(By.XPath("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li")).ToList().Count == 0) { ReadProductDetail(driver_.Url, ref info); } else { var PageCount = driver_.FindElements(By.XPath("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li")).ToList().Count; for (var CurrentPage = 1; CurrentPage <= PageCount;) { List<IWebElement> products = driver_.FindElements(By.XPath("//*[@id=\"chessboard\"]/li/a")).ToList(); foreach (var product in products) { ReadProductDetail(product.GetAttribute("href"), ref info); } //Last Page if (CurrentPage == PageCount) { break; } //Next Page ++CurrentPage; driver_.FindElement(By.XPath(string.Format("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li[{0}]/a", CurrentPage))).Click(); } } } catch (NoSuchElementException) { } this.ProductDetail_.Add("momo", info); driver_.Quit(); if (LocalDriver_ != null) { LocalDriver_.Quit(); } return; }
/// <summary> /// Log a user into the website as an administrator /// </summary> /// <param name="driver"></param> protected void SignInAsAdmin(RemoteWebDriver driver) { //Notice navigation is slightly different than the Java version //This is because 'get' is a keyword in C# driver.Navigate().GoToUrl(BaseUrl + "/User/SignIn"); // Find the text input element by its name driver.FindElement(By.Name("Email")).SendKeys(_adminEmail); driver.FindElement(By.Name("Password")).SendKeys(_adminPass); driver.FindElement(By.CssSelector("button.btn-primary")).Click(); driver.WaitFor(u => u.Url.Contains("Manage")); }
public void Test2() { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.SetCapability("device", "Android"); capabilities.SetCapability("app", "Chrome"); capabilities.SetCapability(CapabilityType.BrowserName, "Browser"); capabilities.SetCapability(CapabilityType.Version, "4.3"); capabilities.SetCapability(CapabilityType.Platform, "WINDOWS"); IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities); driver.Navigate().GoToUrl("http://www.espn.com") ; }
public void GivenThatINavigateToABlogPostThatContainsAnImage() { var driver = new RemoteWebDriver(new Uri("http://localhost"), DesiredCapabilities.HtmlUnitWithJavaScript()); // Find the text input element by its name driver.Navigate(); // Enter something to search for IWebElement element = driver.FindElement(By.Id("")); // Now submit the form. WebDriver will find the form for us from the element //element.S }
private void CheckDriverThenClose(RemoteWebDriver driver) { try { Assert.IsNotNull(driver); driver.Navigate().GoToUrl("http://google.com"); Log.Debug(GetUserAgent(driver)); } finally { driver.Quit(); } }
public void Should_be_able_to_read_text_from_label_when_content_is_more_than_just_text() { var pagePath = Path.Combine(Environment.CurrentDirectory, "markup.html"); driver = new FirefoxDriver(); driver.Navigate().GoToUrl(pagePath); var container = driver.FindElement(By.ClassName("some-class")); var labels = container.FindElements(By.TagName("label")); // This works: Assert.That(labels[0].GetAttribute("class"), Is.EqualTo("some-other-class")); // But not this: Assert.That(labels[0].Text, Is.EqualTo("Alla kommuner")); }
public void TitleIsCorrect() { for (int i = 0; i < 30; i++) { //IWebDriver webDriver = new ChromeDriver(); //IWebDriver webDriver = new PhantomJSDriver(); // TODO ^^ So instead of this we do this: IWebDriver webDriver = new RemoteWebDriver(new Uri("http://localhost:4444"), new DesiredCapabilities()); // ^^ this is how you'd call a Selenium Grid server, the desired capability is used to ask for a particular browser (or set of configuration) // you will need to first run phantomjs.exe --webdriver=4444 // you might run a local instance simply by calling java -jar selenium-grid.jar or something, then register browsers with it // you could also call source labs, browserstack or whatever // When using ChromeDriver you could try reuisng a webdriver session, // but then you could get failing tests interfering with other tests, you can do some work to mitigation this and use things like cookejars to isolate tests // but with PhantomJS giving you a new session each time, you don't have to worry about it. // we had it so that failures would output a screenshot (that would get attached to the test result), this is available through the webdriver api and is support by PhantomJS // we also had the webdriver switchable by config, so that we could quickly switch to a full browser to troubleshoot bugs webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30)); webDriver.Navigate().GoToUrl("http://localhost:3988/"); var header = webDriver.FindElement(By.CssSelector("div.jumbotron > h1")); header.Text.ShouldBe("ASP.NET"); } //var liCount = _webDriver.FindElement(By.Id("test-content")).FindElements(By.TagName("li")).Count; //liCount.ShouldBe(3); // This sort of fiddly stuff, i.e. elements with timeouts, domReady etc... are not as bad as I remember. // because FindElements will wait using the _webdriver implicit wait settings (set when we construct the WebDriver object) // but what if there was already an <li> in the list, it fails! what if the dom exists, but then we replace it with ajax // thats when you might do something explicit like this: //var fiveSecondWait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(5)); //fiveSecondWait.Until(wd => //{ // // do some checks // return true; //}); // We used to queue some javascript so that we know that all synchrounous task had been parse and completed by the browser and we were ready to rock }
public override void SpecifyForBrowser(RemoteWebDriver driver) { given("a non null driver", delegate() { Assert.IsNotNull(driver); when("we goto google.com", delegate() { driver.Navigate().GoToUrl("http://google.com"); then("we can get the user agent", delegate() { expect(() => GetUserAgent(driver).Length >0); }); }); }); }
public static void OpenHtmlUnitDriver() { // initialize a WebDriver instance //IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.HtmlUnit()); IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnit()); // load google search page driver.Navigate().GoToUrl("https://www.google.ca"); // print title Console.WriteLine("Page title: " + driver.Title); // enter search word and submit IWebElement element = driver.FindElement(By.Name("q")); element.SendKeys("Cheese"); element.Submit(); // print title Console.WriteLine("Page title: " + driver.Title); // quit the driver driver.Quit(); }
/// <summary>starts a sauce labs sessions</summary> /// <param name="browser">name of the browser to request</param> /// <param name="version">version of the browser to request</param> /// <param name="platform">operating system to request</param> private IWebDriver _Setup(string browser, string version, string platform) { // construct the url to sauce labs Uri commandExecutorUri = new Uri("<http://ondemand.saucelabs.com/wd/hub>"); // set up the desired capabilities DesiredCapabilities desiredCapabilites = new DesiredCapabilities(browser, version, Platform.CurrentPlatform); // set the desired browser desiredCapabilites.SetCapability("platform", platform); // operating system to use desiredCapabilites.SetCapability("username", Constants.SAUCE_LABS_ACCOUNT_NAME); // supply sauce labs username desiredCapabilites.SetCapability("accessKey", Constants.SAUCE_LABS_ACCOUNT_KEY); // supply sauce labs account key desiredCapabilites.SetCapability("name", TestContext.CurrentContext.Test.Name); // give the test a name // start a new remote web driver session on sauce labs var _Driver = new RemoteWebDriver(commandExecutorUri, desiredCapabilites); _Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30)); // navigate to the page under test _Driver.Navigate().GoToUrl("<https://saucelabs.com/test/guinea-pig>"); return _Driver; }
static void Main(string[] args) { Local local = new Local(); List<KeyValuePair<string, string>> options = new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("key", BROWSERSTACK_ACCESS_KEY), //new KeyValuePair<string, string>("localIdentifier", "identifier"), //new KeyValuePair<string, string>("f", "C:\\Users\\Admin\\Desktop\\"), new KeyValuePair<string, string>("onlyAutomate", "true"), new KeyValuePair<string, string>("verbose", "true"), new KeyValuePair<string, string>("forcelocal", "true"), new KeyValuePair<string, string>("binarypath", "C:\\Users\\Admin\\Desktop\\BrowserStackLocal.exe"), new KeyValuePair<string, string>("logfile", "C:\\Users\\Admin\\Desktop\\local.log"), }; local.start(options); // Run WebDriver Tests IWebDriver driver; DesiredCapabilities capability = DesiredCapabilities.Firefox(); capability.SetCapability("browserstack.user", BROWSERSTACK_USERNAME); capability.SetCapability("browserstack.key", BROWSERSTACK_ACCESS_KEY); //capability.SetCapability("browserstack.localIdentifier", "identifier"); capability.SetCapability("browserstack.local", true); capability.SetCapability("build", "build"); driver = new RemoteWebDriver( new Uri("http://hub.browserstack.com/wd/hub/"), capability ); driver.Navigate().GoToUrl("http://www.google.com"); Console.WriteLine(driver.Title); IWebElement query = driver.FindElement(By.Name("q")); query.SendKeys("Browserstack"); query.Submit(); Console.WriteLine(driver.Title); driver.Quit(); local.stop(); Console.WriteLine("Test Completed."); Console.ReadLine(); }
private static void CrawlFirstPage(Uri startUrl) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArgument("--user-agent=" + _options.UserAgent); var _driver = new RemoteWebDriver(_options.RemoteHubUrl, chromeOptions.ToCapabilities()); try { _driver.Navigate().GoToUrl(startUrl); SaveHtmlAndScreenShot(startUrl, _driver); pageVisitedURLMapping.TryAdd(startUrl, startUrl); _driver.Close(); _driver.Quit(); } catch (Exception ex) { logger.Info(" Thread : " + startUrl.PathAndQuery + " Error at " + ex.StackTrace); _driver.Close(); _driver.Quit(); } }
public void FindPrice() { IWebDriver driver = new RemoteWebDriver(new Uri("http://192.168.1.4:4444/wd/hub"), DesiredCapabilities.Firefox()); driver.Navigate().GoToUrl("http://www.pcstore.com.tw/"); Thread.Sleep(1000); //#id_search_word driver.FindElement(By.CssSelector("#id_search_word")).SendKeys(this.SearchKeyWord_); driver.FindElement(By.XPath("//*[@id=\"top-search\"]/img")).Click(); Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>> info = new Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>>(); for (; ; ) { List<IWebElement> ProductList = driver.FindElements(By.XPath("//*[@id=\"keyad-pro-right3\"]/div[1]/a")).ToList(); foreach (var product in ProductList) { ReadProductDetail(product.GetAttribute("href"), ref info); } try { driver.FindElement(By.XPath("//*[@id=\"container\"]/div[10]/table[1]/tbody/tr/td[5]/a")).Click(); Thread.Sleep(1000); } catch (System.Exception) { break; } } this.ProductDetail_.Add("PcHome", info); if (LocalDriver_ != null) { LocalDriver_.Quit(); } driver.Quit(); return; }
static void DeletesAndAddsShouldBeEvidentOnRefresh( RemoteWebDriver driver, AuthenticatingNavigator navigator ) { using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 ) { navigator.NavigateWithAuthenticate( driver, "tag" ); // Once the 'Add New Tag' button becomes enabled, we know that all tags have been loaded WebDriverWait shortWait = new WebDriverWait( driver, TimeSpan.FromSeconds( 2 ) ); shortWait.Until( d => d.FindElement( By.Id( "add_new_tag" ) ).Enabled ); //TODO TP 1650 - an enabled 'Add New Tag' button doesn't guarantee that the rendering is finished in Chrome; doing some unconditional wait... Thread.Sleep( 1000 ); // Delete all except the first (if there is one) foreach ( IWebElement item in driver.FindElements( By.CssSelector( "button.delete" ) ).Skip( 1 ) ) item.Click(); shortWait.Until( d => d.FindElements( By.CssSelector( "input.tag_name" ) ).Count <= 1 ); // Add a fresh one; give it a name driver.FindElement( By.Id( "add_new_tag" ) ).Click(); var newTagInputElement = driver.FindElements( By.CssSelector( "input.tag_name" ) ).Last(); newTagInputElement.Clear(); newTagInputElement.Click(); var newTagName = new Fixture().CreateAnonymous<string>(); newTagInputElement.SendKeys( newTagName ); string[] tagsAsSubmitted = SaveAndRecordSubmittedTags( driver ); // Need a retry in case the initial load loads data which does not include the (eventually consistent) changes new WebDriverWaitIgnoringNestedTimeouts( driver, TimeSpan.FromSeconds( 7 ) ).Until( _ => { driver.Navigate().Refresh(); // Verify reloading the page shows the same tags pretty quickly return shortWait.Until( d => d.FindElement( By.Id( "add_new_tag" ) ).Enabled && tagsAsSubmitted.SequenceEqual( d.FindElements( By.CssSelector( "input.tag_name" ) ).Select( tagNameEl => tagNameEl.GetAttribute( "value" ).Trim() ) ) ); } ); } }
static void Main(string[] args) { DesiredCapabilities capability = null; IWebDriver driver = null; for (int i = 1; i < 4; i++) { switch (i) { case 1: capability = DesiredCapabilities.Firefox(); capability.SetCapability("BrowserName", "firefox"); break; case 2: capability = DesiredCapabilities.Chrome(); capability.SetCapability("BrowserName", "chrome"); break; case 3: capability = DesiredCapabilities.InternetExplorer(); capability.SetCapability("BrowserName", "internet explorer"); break; default: return; } driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability); driver.Manage().Window.Maximize(); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(10)); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.Navigate().GoToUrl("http://www.baidu.com"); IWebElement searchBox = driver.FindElement(By.Id("kw")); IWebElement searchButton = driver.FindElement(By.Id("su")); searchBox.SendKeys("Shinetech"); searchButton.Click(); driver.Dispose(); } }
private void xmpp_OnLogin(object sender) { if (Connected != null) Connected(this, EventArgs.Empty); //Notifico a tutti la mia presenza Presence p = new Presence(ShowType.chat, "Online"); p.Type = PresenceType.available; xmpp.Send(p); xmpp.OnMessage += new MessageHandler(xmpp_OnMessage); //Mono.Zeroconf.RegisterService rs = new Mono.Zeroconf.RegisterService(); //rs.Name = "_signage_client"; //rs.Port = 80; //rs.RegType = "_tcp"; //rs.Register(); xmpp.Send(new Message("[email protected]/Aramis", "test")); ProcessStartInfo chromedriver = new ProcessStartInfo("chromedriver.exe"); chromedriver.CreateNoWindow = true; chromedriverprocess = Process.Start(chromedriver); DesiredCapabilities capability = DesiredCapabilities.Chrome(); capability.SetCapability("chrome.binary", "chrome-win32\\chrome.exe"); capability.SetCapability("chrome.switches", new List<String>() { "--kiosk", "--disable-translate", "--allow-outdated-plugins", "--profile-directory profiles" }.ToArray()); wd = new RemoteWebDriver(new System.Uri("http://localhost:9515/"), capability); wd.Navigate().GoToUrl("http://www.google.com/"); wd.FindElementByName("q").SendKeys("prova"); }
public void FindPrice() { IWebDriver driver = new RemoteWebDriver(new Uri("http://192.168.1.4:4444/wd/hub"), DesiredCapabilities.Firefox()); //超級商城 driver.Navigate().GoToUrl("https://tw.mall.yahoo.com/"); driver.FindElement(By.XPath("//*[@id=\"srp-ac-bar\"]")).SendKeys(this.SearchKeyWord_); driver.FindElement(By.XPath("//*[@id=\"UHSearchProperty\"]")).Click(); Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>> info = new Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>>(); for (; ; ) { List<IWebElement> products = driver.FindElements(By.XPath("//*[@id=\"srp_result_list\"]/div/div/div[1]/a")).ToList(); foreach (var product in products) { ReadProductDetailMail(product.GetAttribute("href"), ref info); } try { if (driver.FindElement(By.XPath("//*[@id=\"srp_sl_result\"]/div[3]/ul")).FindElements( By.XPath(".//li/a")).ToList().Last().Text == "下一頁") { driver.FindElement(By.XPath("//*[@id=\"srp_sl_result\"]/div[3]/ul")).FindElements( By.XPath(".//li/a")).ToList().Last().Click(); } else { break; } products.Clear(); Thread.Sleep(1000); } catch (NoSuchElementException e) { break; } } //購物中心 driver.Navigate().GoToUrl("https://tw.buy.yahoo.com/"); driver.FindElement(By.XPath("//*[@id=\"srp-ac-bar\"]")).SendKeys(this.SearchKeyWord_); driver.FindElement(By.XPath("//*[@id=\"UHSearchProperty\"]")).Click(); List<IWebElement> buyproducts = driver.FindElements(By.XPath("//*[@id=\"srp_result_list\"]/div/div/div[1]/a")).ToList(); for (; ; ) { List<IWebElement> products = driver.FindElements(By.XPath("//*[@id=\"srp_result_list\"]/div/div/div[1]/a")).ToList(); foreach (var product in buyproducts) { ReadProductDetailBuy(product.GetAttribute("href"), ref info); } try { if (driver.FindElement(By.XPath("//*[@id=\"srp_sl_result\"]/div[3]/ul")).FindElements( By.XPath(".//li/a")).ToList().Last().Text == "下一頁") { driver.FindElement(By.XPath("//*[@id=\"srp_sl_result\"]/div[3]/ul")).FindElements( By.XPath(".//li/a")).ToList().Last().Click(); } else { break; } Thread.Sleep(1000); } catch (NoSuchElementException e) { break; } } this.ProductDetail_.Add("Yahoo", info); driver.Quit(); if (LocalDriver_ != null) { LocalDriver_.Quit(); } return; }
public static LoginPage NavigateToMailRUPage(RemoteWebDriver driver, string baseURL) { driver.Navigate().GoToUrl(baseURL.TrimEnd(new char[] { '/' }) + LoginPage.URL); return GetInstance<LoginPage>(driver, baseURL); }
/// <summary> /// Launch must be called in order to populate the browser and open it. /// </summary> /// <param name="baseUri"></param> /// <param name="browserType"></param> public void Launch(string baseUri, BrowserType browserType = BrowserType.Firefox) { Driver = BrowserDriverFactory.CreateDriver(browserType); Driver.Navigate().GoToUrl(baseUri); }
public static void CrawlPage(Uri startUrl) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArgument("--user-agent=" + _options.UserAgent); chromeOptions.AddArgument("user-data-dir=C:/Debug/" + startUrl.AbsolutePath); var _driver = new RemoteWebDriver(_options.RemoteHubUrl, chromeOptions.ToCapabilities()); try { ConcurrentDictionary<Uri, Uri> pageToVisit = new ConcurrentDictionary<Uri, Uri>(); ConcurrentDictionary<Uri, Uri> PartThreading; pageToVisit.TryAdd(startUrl, null); while (true && pageToVisit.Count > 0) { PartThreading = new ConcurrentDictionary<Uri, Uri>(); logger.Info(_options.Name + " Thread : " + startUrl.PathAndQuery + " Page To Visit Size :{0}", pageToVisit.Count + " SessionId" + _driver.SessionId ); foreach (var pTV in pageToVisit) { PartThreading.TryAdd(pTV.Key, pTV.Value); Uri value; pageToVisit.TryRemove(pTV.Key, out value); } foreach (var Key in PartThreading.Keys) { _driver.Navigate().GoToUrl(Key); SaveHtmlAndScreenShot(Key, _driver); pageToVisit = GetUnvisitedLinks(_driver, Key, _driver.Url, PartThreading, pageToVisit, startUrl); pageVisitedURLMapping.TryAdd(Key, PartThreading[Key]); ValidatePage(_driver, Key, PartThreading[Key]); } logger.Info(" Thread : " + startUrl.PathAndQuery + " Page Finish Visit Size :{0}", pageVisitedURLMapping.Count); } _driver.Close(); _driver.Quit(); } catch (Exception ex) { logger.Info(" Thread : " + startUrl.PathAndQuery + " Error at " + ex.StackTrace); _driver.Close(); _driver.Quit(); } }
public void BVT_BrowserStack() { IWebDriver driver; driver = new RemoteWebDriver( new Uri("http://hub.browserstack.com/wd/hub/"), base.BrowserCapabilities); driver.Navigate().GoToUrl("http://www.google.com/ncr"); Console.WriteLine(driver.Title); IWebElement query = driver.FindElement(By.Name("q")); query.SendKeys("Browserstack"); query.Submit(); Console.WriteLine(driver.Title); if (false == driver.Title.Contains("Google")) { Assert.Fail("Expected: '{0}' and Actual: '{1}'", "Google", driver.Title); } else { Console.WriteLine("Expected: '{0}' and Actual: '{1}'", "Google", driver.Title); } driver.Quit(); }