简体   繁体   中英

Can we switch to another window without using switchTo() method through Selenium webdriver?

如何在不使用Selenium Webdriver中的switchTo()方法的情况下切换窗口?

Answering straight No , you won't be able to switch window without using switchTo() method through Selenium Webdriver .

All the WebDriver commands happen in the context of either the current browsing context or the current top-level browsing context . The current top-level browsing context is represented in the protocol by its associated window handle. When a top-level browsing context is selected using the Switch To Window command, a specific browsing context can be selected using the Switch to Frame command.

Note : The use of the term window to refer to a top-level browsing context is legacy and doesn't correspond with either the operating system notion of a “window” or the DOM Window object.

Driver.SwitchTo().Window(windowHandle)

  • HTTP Method

     POST 
  • URI Template

     /session/{session id}/window 
  • Command

     Driver.SwitchTo().Window(windowHandle) 

Note : Switching window will select the current top-level browsing context used as the target for all subsequent commands. In a tabbed browser, this will typically make the tab containing the browsing context the selected tab.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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