我继续收到“元素不可交互”错误,我认为这是由于在页面上执行操作后链接加载速度不够快所致。隐式驱动程序等待似乎无效,看起来甚至没有设置?
我正在设置隐式等待驱动程序,如下所示:(页面加载似乎无济于事)
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
功能[{mobileEmulationEnabled = false,超时= {implicit = 0,pageLoad = 300000,脚本= 30000} ,hasTouchScreen = false,platform = XP,acceptSslCerts = false,goog:chromeOptions = { debuggerAddress = localhost:63891},acceptInsecureCerts = false,webStorageEnabled = true,browserName = chrome,takesScreenshot = true,javascriptEnabled = true,platformName = XP,setWindowRect = true,unexpantAlertBehaviour = ignore,applicationCacheEnabled = false,rotatable = false,networkConnectionEnabled = false ,chrome = {chromedriverVersion = 2.45.615291(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),userDataDir = C:\ Users \ jxg262 \ AppData \ Local \ Temp \ scoped_dir2012_6758},需要HeapSnapshot = true,unhandledPromptBehavior = Enabled,False ,handlesAlerts = true,version = 71.0.3578.98,browserConnectionEnabled = false,proxy = Proxy(),nativeEvents = true,locationContextEnabled = true,cssSelectorsEnabled = true}]
这似乎表明未设置隐式。难道我做错了什么?有办法在其他地方设置吗?
答案 0 :(得分:0)
隐式超时是Chrome服务器超时,因此请尝试在启动Chrome之前进行设置
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Integer> timeouts = new HashMap<>();
timeouts.put("implicit", 3000);
chromeOptions.setCapability("timeouts", timeouts);
webDriver = new ChromeDriver(chromeOptions);