Skip to content
Advertisement

Using selenium to click on link not working despite correct xpath

So I have the following setup

# Setup webdriver
wait = 10
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get(url)
wait = WebDriverWait(driver, wait)

I then navigate to a certain page – I have attached the inspect part below and want to click on the part highlighted in red

enter image description here

The code to implement this is below:

# Click on link
vs_table_path = "//a[@href='/care/chart/wandv/viewallclientvitals.jsp?ESOLstdvitalid=1&ESOLview=Weights&ESOLclientid=533354']"
vs_table = wait.until(EC.presence_of_element_located((By.XPATH, vs_table_path)))
vs_table.click()

When I run this – it does not open up this link and I get a TimeoutException (from the wait).

I don’t understand what the issue is here – I did the exact same thing on previous parts of the code to navigate the webpage and it worked. I also made sure the xpath matches exactly the attached inspect.

Please see href text below:

//a[@href='/care/chart/wandv/viewallclientvitals.jsp?ESOLstdvitalid=1&ESOLview=Weights&ESOLclientid=533354'] 

              

Advertisement

Answer

try this instead :

wait.until(EC.element_to_be_clickable((By.XPATH, "//a[text()='view all']"))).click()

or

probably try this also :

wait.until(EC.element_to_be_clickable((By.LINK_TEXT, "view all"))).click()

Please refer official docs

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement