isaac
isaac

Reputation: 121

Python Selenium grabbing an element by XPath

I am currently trying to click an X button on the page so it would take me out of the my current page and go back to the home menu. I tried copying it by Xpath but I keep getting an error no such element

//*[@id="uniqName_85_2"]/header/div[2]/div/i[6]

Here is the HTML

<i role="button" aria-label="Close" tabindex="0" class="tableCell
 hi hi-close" data-dojo-attach-event="onclick:trowserExit"> 

Any help would be appreciated. I'm not sure why the xpath isnt working

Upvotes: 0

Views: 52

Answers (1)

KunduK
KunduK

Reputation: 33384

Use WebDriverWait() and wait for element_to_be_clickable() and following xpath.

WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH,"//i[@aria-label='Close' and @role='button]"))).click()

You need to import below libraries

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

Upvotes: 1

Related Questions