简体   繁体   English

Xpath与Selenium Webdriver无效“找不到Xpath”

[英]Xpath not valid with Selenium Webdriver “Xpath not found”

I am using the Selenium WebDriver for VBA to get some information from a website, but first I need to select a "category" and click a button, no problem i've been doing that a few times, but on this website the XPath does not return a valid object. 我正在使用Selenium WebDriver for VBA从网站上获取一些信息,但是首先我需要选择一个“类别”并单击一个按钮,我已经这样做了好几次,但是在该网站上XPath确实可以不返回有效对象。

I suspect the website is a "dynamic format" and it breaks the XPath 我怀疑该网站是“动态格式”,并且破坏了XPath

How do I navigate to the button and click it when it's path is not valid? 当路径无效时,如何导航到该按钮并单击它?

Line of code that is not working: driver.FindElementByXPath("//div[@id=""buttonBar""]/td").Click 无效的代码行:driver.FindElementByXPath(“ // div [@id =”“ buttonBar”“] / td”)。Click

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

The button is the "continuar" on the botton of the page 该按钮是页面底部的“连续”按钮

Thanks for the help! 谢谢您的帮助!

You first need to set the context on the frame to access the button: 您首先需要在框架上设置上下文以访问按钮:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM