python - Selecting Element followed by text with Selenium WebDriver -


I'm using Selenium WebDriver and Python binding to automate some monotonous wordpress functions, and it's up to this point Very simple. I am trying to select a checkbox, but the only way I can identify it is by text. Here is the relevant piece of HTML:

  & lt; Li id = "product_cat-52" & gt; & Lt; Label class = "selectit" & gt; & Lt; Input value = "52" type = "checkbox" name = "tax_input [product_cat] []" id = "in-productcat-52" & gt; Polish Pottery & lt; / Labels & gt; & Lt; / Li & gt;   

My script has only this information to identify this checkbox "polishpottery" string is there a way to select the checkbox that only follows the text?

Already @ Sherwin-Woo said, you have ID or name or class (and most of it Depending on what you want to choose based on the combination), you should select it. There are enough possibilities to do this in your example, although I do not know how the rest of the page looks normally.

After doing this, it has been said that whatever you did was the XPath selector like

  driver.find_element_by_xpath ("// li / label / input [in (.., 'Polish Pottery']] "   

Comments