0

I'm trying to create a script that would click on every link on a given URL, but occasionally there are pop-ups/overlays that appear that block the link.

Would be be possible to detect these pop-ups/overlays using Selenium or Javascript?

I've tried using is_displayed, is_enabled, and EC.element_is_clickable but nothing seems to work.

EDIT: I'm hoping to find a way to detect the blocking element without having to click.

  • 1
    I advice you to include some code you have tried into your question. It will increase the chances of getting an answer and reduce the chances of having your question flagged and removed. – acarlstein May 02 '19 at 21:01
  • 1
    Can you provide the HTML for the pop-up/overlay? – S Ahmed May 02 '19 at 21:50

1 Answers1

0

this using this:

try:
    element.Click()
except ElementNotClickableException as x:
    //handle not being able to click element here, you can try to select the element by taking the attributes that are returned in the exception message, or check the exception message to see if it really is an ad, something like x.Message.Contains("class=pop-up")

Hope it helps

Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143
Valga
  • 459
  • 2
  • 7
  • Would it be possible to detect the blocking element without clicking on it? I probably should have clarified that. Sorry – Joseph Doan May 02 '19 at 21:10
  • can't you create a script to close all the pop-ups in the page before running the test? and you can actually click the elements under these popups using driver.execute_script("arguments[0].click();", element)... More about it here https://stackoverflow.com/questions/34562061/webdriver-click-vs-javascript-click – Valga May 03 '19 at 12:31