admc / wd

A node.js client for webdriver/selenium 2.
Other
1.53k stars 402 forks source link

Globally Change Timeout in waitForXXX #545

Closed RobertMcCoy closed 6 years ago

RobertMcCoy commented 6 years ago

When testing it would be nice to be able to globally set the waitFor timeout rather than needing to make it an argument to every single call to waitFor.

Does this functionality exist and I am overlooking it, or is this a feature that needs added? In the waitFor command in the source it looks like opts.timeout needs to come from the fargs.

jlipps commented 6 years ago

this is as designed for explicit waits. if you want a global timer, use implicit waits.

RobertMcCoy commented 6 years ago

@jlipps Are you referring to the setImplicitWaitTimeout set on the driver? Setting this doesn't seem to change how long waitForElementAccessibilityId waits for an element, and will just timeout after a second. Maybe I am misunderstanding the API usage, here is an example of the code being used:

const driver = wd.promiseChainRemote(serverConfig);
const client = driver.init(iosConfig).setImplicitWaitTimeout(5000);

// ...

await client
        .waitForElementByAccessibilityId("someElementId")
        .click();

Our application uses a loading alert for most screens, and some screens may take upwards of a second or two to load, so it doesn't appear to respect the 5000 in some cases.

jlipps commented 6 years ago

setting the implicit wait timeout changes the server's behavior. just use a regular find element command .elementByAccessibilityId and the server will wait for you.