This section knowledge points:
Positioning of a multi-tier frame or window:
Switch_to_frame ()
Switch_to_window ()
Smart wait:
Implicitly_wait ()
For a modern web application, there are often frames or Windows (window) applications, which poses a challenge to our positioning.
Sometimes we locate an element, the locator is not a problem, but it is not fixed, this time we have to check whether this element is in a frame, Seelnium Webdriver provides a switch_to_frame method, can easily solve this problem.
Frame.html
Inner.html
Driver.switch_to_window ()
It is possible to nest not the frame, but the window, and the true method of the window: Switch_to_window
Usage is the same as Switch_to_frame:
Driver.switch_to_window ("Windowname")
Implicitly_wait ()
Careful words will find that the above example has browser.implicitly_wait (30), its usage should be more intelligent than time.sleep (), the latter can only choose a fixed time waiting, the former can be in a time range intelligent waiting.
Document Explanation:
Selenium.webdriver.remote.webdriver.implicitly_wait (time_to_wait)
Implicitly waits for an element to be found or a command is completed; This method only needs to be invoked once per session
Time_to_wait: Wait Time
Usage:
Driver.implicitly_wait (30)
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/