Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Python+selenium 's cut-in and cut-out of iframe

Shulou Source: shulou.com Published: 2022-06-03 05:41:41 10月02日 Update

Problem found: when logging in to the http://www.126.com automated test, the login name and password can not always be located. It is not possible to use class,xpath,id,css and other methods. Later, after a closer look, I found that the login embedded, that is, iframe, so it has to be cut in order to locate to the element.

Solution:

1. First of all, for the embedded html of iframe, use switch_to.frame to cut into the iframe to get the elements.

two。 When you want to get the external elements of iframe, cut out the iframe with switch_to_default_content (). If you do not cut out, printing with print will report a "dead object" error because the iframe has not been cut out yet.

Tags: Element login location method reason password object that is method time mailbox error problem report test automation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno vpn NVidia macOS Linux