-2

if link : l = link.get_attribute("href") print (l) button=self.driver.find_element_by_xpath( "//button[@id = 'refuse-alert-button' and @data-record " in l +"]")

bug //////////////////////////////////// File "D:\project\odoo_selenium\api\frontend.py", line 233, in refuse_record "//button[@id = 'refuse-alert-button' and @data-record " in l +"]")

  • This sounds like an [X-Y problem](http://xyproblem.info/). Instead of asking for help with your solution to the problem, edit your question and ask about the actual problem. What are you trying to do? – undetected Selenium Feb 22 '19 at 11:20
  • 1
    Please try to format your question more reasonably. – ruohola Feb 22 '19 at 11:32
  • Possible duplicate of [XPath "in" operator](https://stackoverflow.com/questions/13871250/xpath-in-operator) – JeffC Feb 22 '19 at 14:23
  • ^ according to the linked question, the `in` operator is available in XPath 2.0. Selenium only supports XPath 1.0. There is probably another way to do this. Please edit your question and add more details such as the relevant HTML and what you are trying to accomplish. – JeffC Feb 22 '19 at 14:24

1 Answers1

0

What i understood is you want to get element which is matching with the attribute you want to pass in xpath.

//button[@id = 'refuse-alert-button' and @data-record ='" + l + "']

l = link.get_attribute("href") 
    print (l)  
button=self.driver.find_element_by_xpath( "//button[@id = 'refuse-alert-button' and @data-record ='" + l + "']")

In your case

You can use contains though if want partial match

//button[@id = 'refuse-alert-button' and contains(@data-record,'" + l + "')]
NarendraR
  • 7,577
  • 10
  • 44
  • 82