selenium summary of the positioning frame switching

 

1. First of all frame labels frameset, frame, iframe three kinds, frameset is no different with other common label, it will not affect the normal position, so do not cut frameset, frame needs to cut layers.

selenium provides switch_to.frame () method to switch the frame, usually the id and name will be able to solve most problems. But sometimes there is no frame of these two properties, you can use the index to locate and WebElement:

(1) .index from 0, it is determined that the incoming integer parameter with a positioning index, it is determined that the incoming str parameter with id / name positioning.
(2) .WebElement object, that object-find_element series methods made, we can locate an object frame with tag_name, xpath and so on.

2. From the frame cut back to the main document (switch_to.default_content ()), then cut into the frame, we can not continue to operate the main elements of the document, then if you want to operate the main content of the document, you need to switch back to the main document.

3. The nested frame operation (switch_to.parent_frame ()), cut from the sub-frame back to the parent frame.

Released seven original articles · won praise 6 · views 640

Guess you like

Origin blog.csdn.net/weixin_36273267/article/details/103842950