【发布时间】:2020-04-24 15:59:47
【问题描述】:
我一直在尝试使用 selenium 进行自动化操作,需要点击链接,但网页上有谷歌广告,我无法点击按钮。我该如何克服这个问题?
这是代码
elem = browser.find_element_by_link_text('Illinois')
elem.click()
这是错误
ElementClickInterceptedException: Message: element click intercepted: Element <a href="/state/IL">...</a> is not clickable at point (497, 858). Other element would receive the click: <iframe frameborder="0" src="https://tpc.googlesyndication.com/safeframe/1-0-37/html/container.html?2ad90d8b823cd41d3186f3484dae4192" id="google_ads_iframe_/1254144/netronline_com-medrectangle-2_0" title="3rd party ad content" name="" scrolling="no" marginwidth="0" marginheight="0" width="970" height="90" data-is-safeframe="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" data-google-container-id="12" style="border: 0px; vertical-align: bottom;" data-load-complete="true"></iframe>
我也尝试了 webdriver,但出现超时错误
WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, "//a[@href='https://Link.com' and contains(.,'Illinois')]"))).click()
【问题讨论】:
-
请张贴您的 html 或分享 url 如果这个 pulic?
标签: python selenium automation