【问题标题】:Is there a way to set implicit timeouts beyond the driver.manage().timeouts() method?有没有办法在 driver.manage().timeouts() 方法之外设置隐式超时?
【发布时间】:2019-05-30 06:26:55
【问题描述】:

我继续收到“元素不可交互”错误,我认为这是由于在页面上执行操作后链接加载速度不够快。隐式驱动程序等待似乎不起作用,看起来它甚至没有设置?

我正在像这样设置隐式等待驱动程序:(页面加载似乎没有帮助)

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, platform=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_6758}, 需要HeapSnapshot=true, unhandledPromptBehavior=ignore, false,EnabledFileInteractability=false , handleAlerts=true, version=71.0.3578.98, browserConnectionEnabled=false, proxy=Proxy(), nativeEvents=true, locationContextEnabled=true, cssSelectorsEnabled=true}]

这似乎表明没有设置隐式。难道我做错了什么?有没有办法在别处设置这个?

【问题讨论】:

标签: java selenium-chromedriver


【解决方案1】:

隐式超时是 Chrome 服务器超时,所以在启动 Chrome 之前尝试设置它,像这样

ChromeOptions chromeOptions = new ChromeOptions();

Map<String, Integer> timeouts = new HashMap<>();
timeouts.put("implicit", 3000);
chromeOptions.setCapability("timeouts", timeouts);

webDriver = new ChromeDriver(chromeOptions);

【讨论】:

    猜你喜欢
    • 2010-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-19
    • 2019-10-14
    • 2019-10-21
    • 2011-03-19
    • 2021-03-05
    相关资源
    最近更新 更多