Select iframe using Python + Selenium

后端 未结 6 705
Happy的楠姐
Happy的楠姐 2020-11-22 12:13

So, I was absolutely baffled as to how to do this in Selenium, and couldn\'t find the answer anywhere, so I\'m sharing my experience.

I was trying to select an ifram

6条回答
  •  不要未来只要你来
    2020-11-22 13:02

    What finally worked for me was:

            sel.run_script("$('#upload_file_frame').contents().find('img[alt=\"Humana\"]').click();")
    

    Basically, don't use selenium to find the link in the iframe and click on it; use jQuery. Selenium has the capability to run an arbitrary piece of javascript apparently (this is python-selenium, I am guessing the original selenium command is runScript or something), and once I can use jQuery I can do something like this: Selecting a form which is in an iframe using jQuery

提交回复
热议问题