我正在尝试自动导航到外部网站。为此,我需要单击一个按钮(以在fullcalendar日历中显示下一周)。 Fullcalendar addon for Vaadin looks like this。
按钮在HTML中的定义为(Firefox开发者工具):
其xpath定义为:
//*[@id="button"]
所以我在Selenium IDE中添加了click
命令,并在目标字段中添加了以下文本:
xpath=//*[@id="button"]
但是,当然,因为所有按钮(即前一个或今天的按钮)共享相同的ID,所以它不起作用(Failed:
09:44:37
Implicit Wait timed out after 30000ms
。
所以我尝试获取其父容器:
<vaadin-button class="custom-button" theme="icon" tabindex="0" role="button"><iron-icon icon="vaadin:angle-double-right"></iron-icon></vaadin-button>
并将其xpath定义为:
/div[1]/vaadin-vertical-layout/div/vaadin-button[3]
因此在Selenium IDE中,我在目标字段中输入了:
xpath=//div/vaadin-vertical-layout/div/vaadin-button[3]
具有相同的结果。
此外,使用Find target in page
不会突出显示按钮,使用Select target in page
会返回css=calendar-view
并以相同的方式结束(不单击按钮)。
因此,我如何单击此按钮,并且如果Selenium IDE找不到元素,为什么不显示错误?此外,我应该切换Selenium(不是IDE)还是Selenium IDE足以满足我的需求?
[请注意:由于它不是我拥有的外部网站,所以我无法确定哪个vaadin版本正在为该网站提供动力。
任何帮助,不胜感激:-)
使用网站(https://fullcalendar.io/),我写了这些xpath:
上一周:
XPath = "//button[@class='fc-prev-button fc-button fc-button-primary']"
下周:
XPath = "//button[@class='fc-next-button fc-button fc-button-primary']"
今天:
XPath = "//button[@class='fc-today-button fc-button fc-button-primary']"