question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implicit and Explicit Waits in Winium

See original GitHub issue

Hello,

I have stumbled across the following issue: After having clicked on an element, I would like to wait for just 1 second. However, Winium is not waiting for a second neither using “Implicit wait” nor “Explicit wait”. In the first case, an exception occurs, while in the second case, it waits for the default period of time (5 seconds) and then continues with the execution. Please see below the code I’m using and actual results

Implicit wait

driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);

org.openqa.selenium.UnsupportedCommandException: ‘setTimeout’ is not valid or implemented command. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: ‘3.11.0’, revision: ‘e59cfb3’, time: ‘2018-03-11T20:26:55.152Z’ System info: host: ‘NRB248385-A’, ip: ‘172.17.66.11’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_141’ Driver info: org.openqa.selenium.winium.WiniumDriver Capabilities {app: C:\Users\P20009\Desktop\Tra…, args: , debugConnectToRunningApp: false, innerPort: 9998, javascriptEnabled: true, keyboardSimulator: 1, launchDelay: 0, platform: ANY, platformName: ANY} Session ID: AwesomeSession at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40) at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80) at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at org.openqa.selenium.winium.WiniumDriverCommandExecutor.execute(WiniumDriverCommandExecutor.java:78) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545) at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:779) at com.site.pages.PageBase.waitUntilText(PageBase.java:53) at com.site.pages.HomePage.openImportDialog(HomePage.java:38) at com.site.tests.TestSubstances.testSubstance1(TestSubstances.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124) at org.testng.internal.Invoker.invokeMethod(Invoker.java:580) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.privateRun(TestRunner.java:648) at org.testng.TestRunner.run(TestRunner.java:505) at org.testng.SuiteRunner.runTest(SuiteRunner.java:455) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415) at org.testng.SuiteRunner.run(SuiteRunner.java:364) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208) at org.testng.TestNG.runSuitesLocally(TestNG.java:1137) at org.testng.TestNG.runSuites(TestNG.java:1049) at org.testng.TestNG.run(TestNG.java:1017) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Explicit wait

WebDriverWait wait = new WebDriverWait(driver, 1); wait.until(ExpectedConditions.presenceOfElementLocated(By.name("someText")));

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:16

github_iconTop GitHub Comments

2reactions
nguyenquangtaycommented, Jul 18, 2021

Yay, I did it, it works fine, thank @mikeliucc great trick! just replace the driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS) by updateImplicitWaitMs(driver, 5000) haha for the lib, I use import org.apache.http.client.fluent.Request and it works for me, regards!

1reaction
mikeliucccommented, Jun 5, 2021

Hey everyone,

Late to the party, but maybe this might help someone out there…

I did this in Java, and it works for me. Shouldn’t be too hard to translate to other languages.

    protected static void updateImplicitWaitMs(WiniumDriver driver, int waitMs) throws IOException {
        if (driver == null) { return; }
        WiniumDriverCommandExecutor commandExecutor = (WiniumDriverCommandExecutor) driver.getCommandExecutor();
        URL driverUrl = commandExecutor.getAddressOfRemoteServer();
        String timeoutUrl = driverUrl.toString() + "/session/AwesomeSession/timeouts/implicit_wait";
        String postBody = "{ \"SESSIONID\":\"AwesomeSession\", \"ms\":" + waitMs + " }";
        Request.Post(timeoutUrl).bodyByteArray(postBody.getBytes()).execute().returnContent();
    }

Essentially, instead of using standard WebDriver mechanism, I send a POST request to WiniumDriver:

{ "SESSIONID": "AwesomeSession", "ms": ... }

Seems to do the trick. Hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

winium implicit wait is not working
I'm trying to check implicit wait functionality in winium but application is getting freeze while executing the below step.
Read more >
WebDriver Implicit, Explicit and Fluent Wait Examples
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element...
Read more >
Developers - Implicit and Explicit Waits in Winium -
Hello,. I have stumbled across the following issue: After having clicked on an element, I would like to wait for just 1 second....
Read more >
Implicit Wait vs Explicit Wait in Selenium Webdriver
Scope: Implicit wait applies globally, while explicit wait applies locally to a specific element.
Read more >
Selenium Java (Implicit & Explicit) Waits
Explicit Wait - targets a specific scenario ... Imagine a search Button. When you search a large amount of targets, it takes, sets...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found