Tcl - Selenium WebDriver:通过包含的文本查找 div 元素?

Tcl - Selenium WebDriver: Finding div element by contained text?

是否有任何等效的 tcl:

driver.find_elements_by_xpath("//*[contains(text(), 'Lookup Network Elements')]")?

我正在尝试 运行 类似于:

set networkButton [$window element by_xpath "//*\[@class=\"frost-button\"\]//div\[contains(\"Network\")\]"]

但它给我错误

::invalidSelectorError10

你的 contains() 是错误的,它不是在寻找 text() 元素。你需要这样写:

set networkButton [$window element by_xpath "//*\[@class=\"frost-button\"\]//div\[contains(text(), \"Network\")\]"]

set networkButton [$window element by_xpath "//*\[@class=\"frost-button\"\]//div\[text()\[contains(., \"Network\")\]\]"]