我的整个测试套件基于带有SeleniumLibrary (RC)的robotframework。我正在尝试将它移植到Selenium2 (webdriver)。我面临Click 关键字的问题,它不再支持坐标参数。我读过this post,它提到了一个MoveToOffsetAction,但是在从robotframework中看到的Selenium2Library中找不到它。我还读到webdriver有一个click_at(定位器,coordString)
总之,我想知道如何将坐标转换为Selenium2关键字或一组关键字。
非常感谢你的帮助,
皮埃尔
发布于 2013-01-29 09:41:03
在Selenium2 API中,没有使用协调器单击元素的选项。
但是您可以使用Action类来解决这个问题。
尝试以下代码:
//Assume driver is instantiated somewhere properly.
WebElement ele = driver.findElement(By.xpath(Element locator));
Actions builder = new Actions(driver);
builder.moveToElement(ele, 100, 200).click().perform();通过使用上面的代码,您可以使用协同(此处按钮)移动到特定的元素,并能够单击。
有关更多信息,http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/interactions/Actions.html
https://stackoverflow.com/questions/14578802
复制相似问题