ElementNotVisibleException : Selenium Python

I have checked all previous similar issues, they are not applicable to my case.

   try:
      element = wait.until(
      EC.presence_of_element_located((By.XPATH, "//*[@id='_ariaId_73.folder'] | //*[@id='_ariaId_133.folder']"))
   )
   except: 
      print "403 : Monitoring Not Found"

element.click()

It is not going to enter into exception block also, but it is still throwing ElementNotVisibleException for element.click() method.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

A few words about the solution:

  1. Expected conditions with clause presence_of_element_located() relates to an expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible. The locator used to find the element returns the WebElement once it is located. Hence we have to change the clause from presence_of_element_located() to visibility_of_element_located() which relates to an expectation for checking that an element, known to be present on the DOM of a page, is visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0. element is the WebElement returns the (same) WebElement once it is visible.
  2. Moving forward you have tried to invoke click() method for the WebElement. So instead of presence_of_element_located() we will use the element_to_be_clickable() clause.
  3. Here is your own code with minor changes :
    try:
        element = wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='_ariaId_73.folder'] | //*[@id='_ariaId_133.folder']")))
    except: 
        print "403 : Monitoring Not Found"
    element.click()


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x