0

Normally I use the xpath to click on text of webpages. But now maybe because it's a table it doesnt work. I want to click on "SNOW Microsoft 2019-03-26.csv" text that is unique in the table. My code is:

browser.find_element_by_xpath("//table[@id='grdReports']/div[3]/table/tbody/tr[1]/td[3]").click()

Error: can't find the xpath

HTML looks like:

html

3 Answers 3

1

Try the following xpath:

//table[@role='grid']//tbody/tr/td[text()='SNOW Microsoft 2019-03-26.csv']

Note: i am not sure if there is two spaces between Microsoft and 2019

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

Comments

1

I would just use

browser.find_element_by_xpath("//td[contains(text(),'SNOW Microsoft 2019-03-26')]").click()

Comments

0

Element with grdReports id is a div, not table:

browser.find_element_by_xpath("//div[@id='grdReports']/div[3]/table/tbody/tr[1]/td[3]").click()

Also you can try shorter xpath:

//*[@id='grdReports']//tr[@role='row']/td[3]

Css selector:

#grdReports tr[role=row] > td:nth-child(3)

Comments

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.