【发布时间】:2018-03-28 15:29:09
【问题描述】:
我有一个使用 Vaadin 框架开发的应用程序,现在我需要单击 Canvas 上的矩形多边形。以下是 html 代码 这里我提供 Html 代码
<canvas width="1920" height="524" class="ol-unselectable" style="width: 100%; height: 100%;"></canvas>
我尝试使用使鼠标移到多边形上并单击的操作。
int x = (int) 5638326.333511386;
int y = (int) 2580101.9711508946;
driver.get("http://localhost:8080/internship");
WebElement ele = driver.findElement(By.xpath("//canvas[@class='ol-unselectable']"));
// driver.findElement(By.tagName("canvas"));
//driver.findElemet(By.className("ol-unselectable"));
try {
Actions builder = new Actions(driver);
builder.moveToElement(ele, x, y);
builder.clickAndHold();
builder.release();
builder.perform();
} catch (Exception e) {
// do nothing
}
我收到以下错误
org.openqa.selenium.NoSuchElementException:无法定位元素: //canvas[@class='ol-unselectable'].
任何人都可以建议一些示例如何在画布上找到带有坐标的多边形并点击它。
【问题讨论】:
标签: java canvas selenium-webdriver action polygon