0

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'] 

              

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

13 Comments

I was just going to write exactly that :)
@C.Peck : I would still prefer LINK_TEXT :)
Interesting, I personally only use xpath and css selector (mostly all CSS Selectors), sometimes things don't work as I expect with NAME, CLASS_NAME, LINK_TEXT, etc
@C.Peck : with CSS you will not have much issues, cause their engines are same across almost every browser. Xpath does not have consistency across different browser, now if they there are multiple linkText in a single page then we can't rely on linText for obvious reasons. I rarely use className, that's something I don't want to use.
@cruisepandey - thanks this works, but only issue is that I have multiple 'view all' on the webpage, hence why I used the href above. How can I differentiate between different 'view alls'?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.