Reputation: 1114
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:
Upvotes: 0
Views: 1250
Reputation: 3717
I would just use
browser.find_element_by_xpath("//td[contains(text(),'SNOW Microsoft 2019-03-26')]").click()
Upvotes: 1
Reputation: 12255
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)
Upvotes: 0
Reputation: 2814
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
Upvotes: 1