Selenium Webdriver选择新窗口C# [英] Selenium webdriver selecting new window c#
问题描述
尝试在C#中使用Selenium Webdriver编写一些测试用例,但遇到无法确定如何解决的情况
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 patient, select a patient then a new window opens and then assert various items on the window
我的问题是我无法选择新窗口来声明任何内容,它不是弹出窗口,它是全新的浏览器窗口,但是没有窗口标题/名称来标识它,我该怎么办?能够将驱动程序焦点切换到此窗口?
my issue is i'm unable to select the new window to assert anything from, it's not a pop-up window, it's a full new browser window but it has no window title/name to identify it by, how would I be able to switch driver focus to this window?
预先感谢
推荐答案
在Selenium WebDriver中,这真的很容易.通过使用SwitchTo方法
It is really easy in Selenium WebDriver. By using SwitchTo method
driver.SwitchTo().Window(driver.WindowHandles.Last());
也请参阅此博客文章
http://binaryclips .com/2015/03/13/selenium-webdriver-in-c-switch-to-new-window/
这篇关于Selenium Webdriver选择新窗口C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!