Selenium webdriver window handles c# switchTo failed

后端 未结 5 1257
广开言路
广开言路 2021-02-10 02:11

Here comes 2 windows pop out during the testing.

my code:

string BaseWindow = driver.CurrentWindowHandle;                 
ReadOnlyCollection

        
5条回答
  •  忘了有多久
    2021-02-10 02:31

    IJavaScriptExecutor js = driver as IJavaScriptExecutor;
    js.ExecuteScript("window.open()");
    String ventanaPrincipal = driver.CurrentWindowHandle;
    List listWindow = new List(driver.WindowHandles);
    driver.SwitchTo().Window(listWindow[1]);
    driver.Navigate().GoToUrl("http:www.google.com");
    IWebElement search = driver.FindElement(By.Name("q"));
    search.SendKeys("RPA");
    

提交回复
热议问题