简体   繁体   English

如何使用Selenium IDE切换窗口?

[英]How do I switch windows with the selenium IDE?

The instruction here: 这里的说明:

http://www.thoughtworks-studios.com/twist/2.3/help/how_do_i_handle_popup_in_selenium2.html http://www.thoughtworks-studios.com/twist/2.3/help/how_do_i_handle_popup_in_selenium2.html

say "In Selenium 2(WebDriver), testing popup windows involve switching the driver to the popup window and then running the corresponding actions. " 说“在Selenium 2(WebDriver)中,测试弹出窗口涉及将驱动程序切换到弹出窗口,然后运行相应的动作。”

I am using the selenium IDE to build and run my test cases. 我正在使用Selenium IDE来构建和运行测试用例。 Where exactly do I put the above java code? 上面的Java代码到底放在哪里?

I cannot modify the source code myself but I can do whatever I want in Selenium. 我自己不能修改源代码,但是我可以在Selenium中做任何我想做的事情。

The code that is mentioned in the link - it's pure Java. 链接中提到的代码-它是纯Java。 You don't need to do any modifications of your site JavaScript if you want to switch between windows. 如果要在Windows之间切换,则无需对网站JavaScript进行任何修改。 You can do do any test automation using WebDriver library. 您可以使用WebDriver库执行任何测试自动化。

browser is an instance of WebDriver class and it has switchTo() method. browserWebDriver类的实例,它具有switchTo()方法。 In other binding languages (C#, Ruby, Python) there are similar methods for the same purpose. 在其他绑定语言(C#,Ruby,Python)中,出于相同的目的有类似的方法。

Whenever you click on a link that opens a new window or even when you open a new window by your own code ,You can use the code given in the link to select the window and perform any operation in that window. 每当您单击打开一个新窗口的链接时,甚至当您使用自己的代码打开一个新窗口时 ,都可以使用链接中提供的代码来选择窗口并在该窗口中执行任何操作。

You have nothing to do with the source code.The code given will serve all the purpose. 您与源代码无关,给出的代码将满足所有目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM