在IE浏览器中运行代码时遇到以下异常错误。但是,同样可以正常运行Firefox和Chrome浏览器。有人可以帮忙吗?
我试图在IE浏览器中运行以下代码,并尝试单击页面https://en.wikipedia.org/wiki/Selenium_%28software%29上的链接“创建按钮”。但是链接永远不会被点击,相同的代码在Firefox中可以正常工作。 能否请您告知我是否需要进行任何更改
公共类ClickIE {
public static void main(String[] args) throws InterruptedException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("requireWindowFocus", true);
System.setProperty("webdriver.ie.driver", "C:\\Users\\Nitin\\IEDriverServer_x64_3.14.0\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver(caps);
driver.get("https://en.wikipedia.org/wiki/Selenium_%28software%29");]
Thread.sleep(5000);
driver.manage().window().maximize();
driver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]/ul/li[4]/a")).click();
String url = driver.getCurrentUrl();
if(url.contains("wikipedia")) {
System.out.println(url+" its a internal link - Passed");
}
else {
System.out.println(url+" its a external link - Failed");
}