Xpath对Selenium Web驱动程序无效”;Xpath未找到”;

Xpath not valid with Selenium Webdriver "Xpath not found"

本文关键字:Xpath 无效 Selenium Web 驱动程序      更新时间:2023-09-26

我正在使用Selenium WebDriver for VBA从网站获取一些信息,但首先我需要选择一个"类别"并单击一个按钮,没问题,我已经做了几次了,但在这个网站上,XPath没有返回有效的对象。

我怀疑这个网站是一个"动态格式",它破坏了XPath

当按钮的路径无效时,我如何导航到该按钮并单击它?

不起作用的代码行:驾驶员FindElementByXPath("//div[@id="buttonBar"]/td")。单击

网站:http://www.ocepar.org.br/ocepar/cooperativasPR/consultaPorRamo.html

按钮是页面底部的"continuar"

谢谢你的帮助!

您首先需要在框架上设置上下文以访问按钮:

Dim driver As New FirefoxDriver
driver.Get "http://www.ocepar.org.br/ocepar/cooperativasPR/consultaPorRamo.html"
driver.SwitchToFrame "buttons"
driver.FindElementById("buttonBar").Click