Selecting xpath using a variable in selenium 2
jeanid last edited by user
I am doing a selenium automation where I want to pass the variable into the XPath and select the element.
The xpath which I am trying looks like:
browser.find_element_by_xpath("//span[contains(.,'SEM W880 Black')]")
I would like to pass the text
SEM W880 Blackas a variable to the XPath. How can I do it using python 3?
At first glance, this appears to be a Python question rather than a QA question. The answer to the Python question is something like,
x = 'SEM W880 Black' browser.find_element_by_xpath("//span[contains(.,'" + x + "')]")
If I misunderstood you, please update the question.