Win*_*ags 5 python selenium xpath
我正在尝试使用XPath Selenium
for Python 找到一个Web元素.web元素应包含文本"Chocolate"但不包含"Dark".
我已经尝试过这种语法,但没有让它起作用(请注意parantheses):
choco = driver.find_element_by_xpath("//*[text()[contains(., 'Chocolate')] and not[[contains(., 'Dark')]]]")
Run Code Online (Sandbox Code Playgroud)
以下是使用换行符和串联以获得可读性的相同代码:
choco = driver.find_element_by_xpath((
"//*[text()[contains(., 'Chocolate')]" +
"and not[[contains(., 'Dark')]]]"
))
Run Code Online (Sandbox Code Playgroud)
请尝试以下操作XPath
,如果发生任何错误,请告诉我:
//*[contains(text(), "Chocolate")][not(contains(text(), "Dark"))]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5388 次 |
最近记录: |