Selenium+python Automation 95-pop-up box can't locate

Source: Internet
Author: User

Objective

Some small partners learned selenium alert, no matter what pop-up box to use alert, this is not working, see the Popup box, first to determine whether it is alert, is to use, not the words certainly can not be used.

    • Some pop-up boxes are div layers, which are like normal positioning methods

    • Some pop-up boxes are nested IFRAME layers, which can be switched by IFRAME

    • Some pop-up boxes compare pits, which are embedded in a window, and this is what this article is about.

Encounter problems

1. Recently a small partner encounters a popup box positioned like this, a pop-up box that looks normal

2. The following attempt was made to meet this problem:

    • First of all, this is definitely not alert, so you can't use alert to locate
    • Then see if there is an IFRAME, after viewing the element, to find no IFRAME
    • There's no way to fix the sleep time waiting in front.
Solve the problem

1. Through the print to get all the windows, found that actually print is two handle, that is, this surface appears to be a window, actually embedded another window.

# 上海悠悠# 打印所有的handleall_handles = driver.window_handlesprint(all_handles)# 切换到新的handle上driver.switch_to.window(all_handles[1])

2. Find the cause of the problem, the next simple, first switch to a new window, and then use the usual positioning method can be

Selenium+python Automation 95-pop-up box can't locate

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.