0

I am currently using an xpath to check if the id and placeholder match:

I have written this xpath, however I am having issues with escapes. I am not sure how to approach this

self.driver.find_element_by_xpath("//input[@id="searchvalue" and @placeholder="Searched for: L1-Multi-level Combo   contains \'Corporate\General Counsel's Office (GCO)\'"]").click()

This is how my HTML code looks like:

<input type="text" name="searchvalue" id="searchvalue" placeholder="Searched for: L1-Multi-level Combo   contains 'Corporate\General Counsel's Office (GCO)\'" label="Search" title="Searched for: L1-Multi-level Combo   contains 'Corporate\General Counsel's Office (GCO)\'" class="uneditable-inputRight searchtext" onkeypress="if((event&amp;&amp;event.which==13)||(window.event&amp;&amp;window.event.keyCode==13)){quickSearchArcadia(gbappid, false, gbentity);}" onfocus="showSearchOptions()">
user7242550
  • 241
  • 4
  • 17

1 Answers1

1

Usually using id attribute should be enough to locate required element as it have to be unique value

self.driver.find_element_by_id("searchvalue")

but if you still want to use placeholder attribute also, try below expression:

self.driver.find_element_by_xpath('//input[@id="searchvalue" and @placeholder="Searched for: L1-Multi-level Combo   contains \'Corporate\\General Counsel\'s Office (GCO)\\\'"]')
Andersson
  • 49,746
  • 15
  • 64
  • 117