Selenium webdriver selecting new window c#

前端 未结 6 1208
清歌不尽
清歌不尽 2020-12-15 07:01

Trying to write some test cases using selenium webdriver in c# and have a scenario which i\'m unsure of how to resolve

user scenario is searching a table for a patie

6条回答
  •  情深已故
    2020-12-15 07:41

            IWebDriver _driver = new FirefoxDriver();
            _driver.Navigate().GoToUrl("https://www.google.com");
    
            ReadOnlyCollection WindowHandles = _driver.WindowHandles;
            foreach (string item in WindowHandles)
            {
                _driver.SwitchTo().Window(item);
                string browserTitle = _driver.Title;
                string browserPageSource = _driver.PageSource;
                string browserURL = _driver.Url;
            }
    

    Use ReadOnlyCollection and handle browser, get the title of your window and compare and get focus on your desire browser window.

提交回复
热议问题