카테고리 없음
[인터넷 익스플로러] IE에서 selenium2가있는 요소를 클릭하십시오.
행복을전해요
2021. 1. 19. 08:26
공식적으로 IE11은 현재 WebDriver의 지원 목록에 없지만 해결을 위해 먼저 요소에 포커스를 이동 한 다음 클릭을 수행 할 수 있으며 이것이 실패하면 자바 스크립트 클릭 방법을 사용하여 클릭 해 볼 수 있습니다.
try {
Actions action = new Actions(driver);
WebElement element = driver.findElement(By.xpath("XPATH_HERE"));
if (element != null) {
action.moveToElement(element).build().perform();
element.click();
return;
}
throw Exception("Element not found to perform click");
}catch (Exception e) {
try {
(new JavascriptLibrary()).executeScript(driver, "arguments[0].click()", driver.findElement(By.xpath("XPATH_HERE")));
return;
}
} catch (Exception e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
출처
https://stackoverflow.com/questions/22007824