java - 有没有办法在 driver.manage().timeouts() 方法之外设置隐式超时?
问题描述
我继续收到“元素不可交互”错误,我认为这是由于在页面上执行操作后链接加载速度不够快。隐式驱动程序等待似乎不起作用,看起来它甚至没有设置?
我正在像这样设置隐式等待驱动程序:(页面加载似乎没有帮助)
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
功能 [{mobileEmulationEnabled=false, timeouts={implicit=0, pageLoad=300000, script=30000},hasTouchScreen=false,平台=XP,acceptSslCerts=false,goog:chromeOptions={debuggerAddress=localhost:63891},acceptInsecureCerts=false,webStorageEnabled=true,browserName=chrome,takeScreenshot=true,javascriptEnabled=true,platformName=XP,setWindowRect =true, unexpectedAlertBehaviour=ignore, applicationCacheEnabled=false, rotatable=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387), userDataDir=C:\Users\jxg262\AppData\Local\Temp\scoped_dir2012_6} =true,unhandledPromptBehavior=ignore,pageLoadStrategy=normal,strictFileInteractability=false,databaseEnabled=false,handlesAlerts=true,版本=71.0.3578.98,browserConnectionEnabled=false,proxy=Proxy(),nativeEvents=true,locationContextEnabled=true,cssSelectorsEnabled=true }]
这似乎表明没有设置隐式。难道我做错了什么?有没有办法在别处设置它?
解决方案
隐式超时是 chrome 服务器超时,所以在启动 Chrome 之前尝试设置它,像这样
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Integer> timeouts = new HashMap<>();
timeouts.put("implicit", 3000);
chromeOptions.setCapability("timeouts", timeouts);
webDriver = new ChromeDriver(chromeOptions);
推荐阅读
- java - 从 XML 中提取属性值
- java - gradle:没有源任务':processTestResources'和':processtResources'
- swiftui-navigationlink - 后退按钮跳过 View1 -> View2 -> View3 NavigationLink 中的视图
- json - 如何使用 NLP 从条件语句中提取规则?
- swift - 无法在 swift 中为 tableview 单元格图像添加 Tapgesture
- google-maps - Google Maps JS API - 根据缩放级别调整所有自定义标记的大小
- vue.js - Vue 强制组件在可见之前渲染到 DOM
- python - 有没有办法将多对多对象关系变成字典?
- react-native - 屏幕更改时标签栏图标未完全居中
- c# - c#获取文本框中输入的值并根据选中的 2 个单选按钮执行计算并在标签中显示结果