在下面的程序中; getTitle() 返回错误的 o/P:
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver",
"E:\\Technologies\\Automation-Selenium\\Selenium Files\\geckodriver.exe");
System.setProperty("webdriver.ie.driver",
"E:\\Technologies\\Automation-Selenium\\Selenium Files\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.google.co.in");
String title = driver.getTitle();
System.out.println(title);
}
Eclipse 中的输出: 网络驱动程序 (为什么不谷歌?)
最佳答案
IEdriver
会发生这种情况;因为每当首先启动 IEDriver
时,它都会打开以下带有“WebDriver”标题的屏幕:
因此,您只需再等待几秒钟即可导航到实际网址,例如您的情况 www.google.com
。
关于java - getTitle() 在 Selenium 中未显示正确的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43704509/