无法通过在 Odoo 中按索引使用 xpath 找到按钮
Can't find button by using xpath by index in Odoo
我在 odoo 应用程序中使用 selenium python webdriver,在 odoo 中,当在他的基本模块中单击通过邮件发送时,selenium ide returns 它的 xpath 为 xpath=(//button[@type='button'])[34]
& 我在 webdriver 代码中将其用作 browser.find_element_by_xpath("(//button[@type='button'])[34]").click()
。它不是 运行ning 并且命令行显示以下错误 -
selenium.common.exceptions.NoSuchElementException: Message: Unable to
locate element:
{"method":"xpath","selector":"(//button[@type='button'])[35]"}
这背后的原因是什么?也给我建议和正确的代码,这样它就会 运行
根据 OP 的评论,请尝试使用以下代码点击 发送 按钮。
browser.find_element_by_xpath("//span[.='Send']").click()
这将定位 span
元素 innerHTML/text 作为 发送 并点击它。
我在 odoo 应用程序中使用 selenium python webdriver,在 odoo 中,当在他的基本模块中单击通过邮件发送时,selenium ide returns 它的 xpath 为 xpath=(//button[@type='button'])[34]
& 我在 webdriver 代码中将其用作 browser.find_element_by_xpath("(//button[@type='button'])[34]").click()
。它不是 运行ning 并且命令行显示以下错误 -
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"(//button[@type='button'])[35]"}
这背后的原因是什么?也给我建议和正确的代码,这样它就会 运行
根据 OP 的评论,请尝试使用以下代码点击 发送 按钮。
browser.find_element_by_xpath("//span[.='Send']").click()
这将定位 span
元素 innerHTML/text 作为 发送 并点击它。