每当我在我的机器上运行任何测试时,我都会收到以下代码错误:
org.openqa.selenium.TimeOutException: timeout
(Session info: chrome=60.0.3112.78)
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e2e7cab51de5ba8),platform=Linux 4.4.0-87-generic x86_64)(WARNING:The server did not provide any stacktrace information)
Command duration or timeout: 10.02 seconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'oem-X555LJ', ip='127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-87-generic', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities[{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.31.488763 (092de99f48a300323ecf8c2a4e2e2e7cab51de5ba8), userDataDir=/tmp/.org.chromium.Chromium.0teumv}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=60.0.3112.78, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true cssSelectorsEnabled=true, setWindowsRect=true, unexpectedAlertBehaviour=}]
Session ID: ...
注意事项:
我正在访问带有SSL证书的URL,因此,将凭据放在以下格式中:
https://id:password@website
每当我尝试访问其他网站时,它的工作正常。
以下是我生成chrome实例的方式....:
package SeLib;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Reporter;
public class NewChrome {
public static WebDriver Generate(Boolean maximized, DesiredCapabilities capabilities){
WebDriver driver;
driver = new ChromeDriver(capabilities);
Reporter.log("The browser is opened now");
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
if(maximized){
driver.manage().window().maximize();
Reporter.log("The browser is maximized");
}
return driver;
}
public static WebDriver Generate(Boolean maximized) throws InterruptedException{
WebDriver driver;
ChromeOptions options = new ChromeOptions();
//options.addArguments("--start-maximized"); // gives problems with data provider
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(capabilities);
Reporter.log("The browser is opened now");
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
if(maximized){
driver.manage().window().maximize();
Reporter.log("The browser is maximized");
}
return driver;
}
}
我试过了:
使用try / catch并在捕获到异常时刷新驱动程序 - &gt;同样的结果,错误仍然存在。
删除隐式超时 - &gt;错误仍然存在。
更新chromedriver / chrome / selenium服务器 - &gt;错误仍然存在。
我不确定这是在我正在使用的网站上的错误,或者我的代码是否有错误或者某些事情发生了故障。
问题是,我从未改变过我的代码,但是由于出现此错误而突然停止工作,因此IDK位于问题的根源。
谢谢你,感谢任何帮助。
杰克逊。