我正在尝试使用Selenium3中的driver.close()
关闭浏览器。但它不起作用。请帮帮我
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "E:\\Phani\\Tools\\geckodriver.exe");
WebDriver wd = new FirefoxDriver();
wd.get("https://google.com");
try{
wd.close();
}catch(Exception e){
System.out.println("---------------------------------------------");
System.out.println(e.getMessage());
System.out.println("---------------------------------------------");
//System.out.println(e.getStackTrace());
}
}
}
我在关闭()期间遇到以下错误。
---------------------------------------------
Failed to interpret value as array
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'PCNAME-PC', ip: '192.168.0.105', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, appBuildId=20160623154057, version=47.0.1, platform=XP, proxy=Proxy(), command_id=1.0, specificationLevel=0.0, acceptSslCerts=false, browserVersion=47.0.1, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, takesElementScreenshot=true, javascriptEnabled=true, platformName=Windows_NT, device=desktop}]
Session ID: b5fa76b7-80b1-49d1-806e-cee7032259ef
---------------------------------------------
答案 0 :(得分:1)
我没有看到您在代码中执行任何其他测试,因此您可以使用wd.quit();
而不是close()