在硒测试执行中,我得到了:
未知错误:元素...在点上无法点击 (1147,21)。其他元素将收到点击:<跨度 id =" schoolName _"> ...(会话信息:chrome = 59.0.3071.115)
代码从这里开始:
List<WebElement> button = driver.findElements(By.xpath("//*[@class='btn btn-primary']"));
for (WebElement firstbutton : button) {
int count = 1;
System.out.println("count is " + count + " Hence it should click he button if button is displayed : ");
if (count == 1) {
// ((JavascriptExecutor)
// driver).executeScript("scroll(0,400)");
// act.moveToElement(firstbutton).click();
firstbutton.click();
System.out.println("Save button is clicked");
break;
} else {
System.out.println("Button is already clicked");
}
}
答案 0 :(得分:0)
您需要使用焦点或滚动该元素。您也可能必须使用明确等待。
measurements
如果仍无效,请使用WebElement firstbutton= driver.findElement(By.xpath("Your Element"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
actions.perform();
JavascriptExecutor