I am trying to use a label to identify the next page button on the web search page, I currently have the code
next_page = driver.find_element_by_xpath(//label[contains(text(),'Page'+str(page_no+1))]//ancestor:div//input)
I got to this stage through this link here: Unable to locate element for LABEL with the XPath expression
I am working in Spyder and it says that this is invalid syntax and won't run the code. I'm not sure why as it seems correct according to the previous answer I followed.
Can someone point out what is wrong with this to me please or identify an alternative code I can use to find element by a label?
I solved this by finding a clickable point for the 'Next page' button, which appeared as a title. I then used this in the code as follows:
driver.find_element_by_xpath('//*[@title="Next page"]').click()
2.1m questions
2.1m answers
60 comments
57.0k users