-1

I've got id="phone_123456_option". There's no fully static part in code to find the element in other way. I can't also use only start-with, for sure I need also refer to option. So I guess I need to match start-with and contains (or ends-with?) in one line of code using xpath. Does anybody know how to do it properly?

In python and selenium now I can use:

driver.find_element_by_id("phone_123456_option").click()

I need to create a python, not xml, xpath: //*[@id="phone_123456_option"] - How to properly remove dynamic number and refer to phone and option?

ann
  • 113
  • 2
  • 3
  • 9

1 Answers1

3

The simplest way to do this:

driver.find_element_by_xpath("//div[starts-with(@id, 'phone') and contains(@id, 'option')]").click()