Python: Selenium xpath to find element with case insensitive characters?

后端 未结 1 651
面向向阳花
面向向阳花 2021-01-24 21:09

I am able to do this

search = \"View List\"
driver.find_elements_by_xpath(\"//*/text()[normalize-space(.)=\'%s\']/parent::*\" % search)

but I n

1条回答
  •  有刺的猬
    2021-01-24 21:27

    The lower-case() function is only supported from XPath 2.0. For XPath 1.0 you will have to use translate().

    Example code is given in this stackoverflow answer.

    Edit: The selenium python bindings site has a FAQ - Does Selenium 2 supports XPath 2.0 ?:

    Ref: http://seleniumhq.org/docs/03_webdriver.html#how-xpath-works-in-webdriver

    Selenium delegate XPath queries down to the browser’s own XPath engine, so Selenium support XPath supports whatever the browser supports. In browsers which don’t have native XPath engines (IE 6,7,8), Selenium support XPath 1.0 only.

    0 讨论(0)
提交回复
热议问题