Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling press() on control that was not found leads to follow up errors #304

Closed
brunohaller opened this issue Jul 8, 2022 · 4 comments · Fixed by #309
Closed

Calling press() on control that was not found leads to follow up errors #304

brunohaller opened this issue Jul 8, 2022 · 4 comments · Fixed by #309

Comments

@brunohaller
Copy link

Describe the bug
I am using the .press() method as mentioned in https://ui5-community.github.io/wdi5/#/usage?id=press
When the control was not found, the press() method keeps on looping (in native wdio until timeout?) and producing errors in the log not finding an "undefined" control:

To Reproduce

    const control = await browser
      .asControl({
        selector: {
          id: "controlThatDoesNotExist",
        },
      });
    await control.press();

Expected behavior
The press method should immediately fail, if the control could not be found instead of trying to look up an element with undefined id.

Logs/Console Output

[0-0] 2022-07-08T19:15:45.873Z INFO webdriver: COMMAND findElements("xpath", "//*[@id="undefined"]")
[0-0] 2022-07-08T19:15:45.874Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session/efcd66f31c05c1ff148fe1fd10cf738f/elements
[0-0] 2022-07-08T19:15:45.874Z INFO webdriver: DATA { using: 'xpath', value: '//*[@id="undefined"]' }
[0-0] 2022-07-08T19:15:45.885Z INFO webdriver: RESULT []

Runtime Env (please complete the following information):

  • wdi5/wdio-ui5-service-version: 0.9.9
  • UI5 version: 1.102.0
  • wdio-version (output of wdio --version): 7.20.5
  • node-version (output of node --version): v14.19.3
  • OS: Windows 10
  • Browser + Version Chrome 103
@brunohaller
Copy link
Author

Additional information: Basically this is a general issue with all methods that are called after a control has not been found / not been successfully initialized. In the case of a press event() it is special, as it causes the above error.

But generally, if for example calling a method like "getText()" on a control that was not found, you will get follow up errors like
getText() is not a function. Native WDIO seems to handles this situation slightly different and tells you in a generic way something like Can not call getText(), because element ... could not be found.

@vobu
Copy link
Contributor

vobu commented Jul 17, 2022

thanks for providing detailed insight into failed control localization 👍
and you're right, the retries on not-located controls is something wdio-native - i am not aware of an option to short-circuit this.
however we sure could improve the error message on non-existent and/or failed API-calls.
Source is here:

result: `function ${methodName} does not exist on control ${metadata.getElementName()}!`,

want to give it a shot 🤗 ?

@brunohaller
Copy link
Author

brunohaller commented Jul 18, 2022

I think the error message is not the main problem.

In our environment for some weird reason we have a huge wdio timeout of 2 minutes, that means after a failed control location and invoking press(), we get 2 minutes long the above error message that no control with id undefined can be found. This is distracting a lot from the actual problem, which is correctly reported.

I think the code is here.

const id = await Promise.resolve(this._domId)
const webelement = await $(`//*[@id="${id}"]`)
await webelement.click()

Could that be improved somehow to not even try finding an element if the control is not initialized? I am not sure how that should be done exactly and at which places, but I assume at least for `press()`` it would be helpful, as looking for an id 'undefined' never makes sense.

@vobu
Copy link
Contributor

vobu commented Jul 18, 2022

I think the code is here.

const id = await Promise.resolve(this._domId)
const webelement = await $(`//*[@id="${id}"]`)
await webelement.click()

Could that be improved somehow to not even try finding an element if the control is not initialized? I am not sure how that should be done exactly and at which places, but I assume at least for `press()`` it would be helpful, as looking for an id 'undefined' never makes sense

good idea - makes absolute sense, we'll do that 👍
might take a couple of days though as almost all of the core contributors are on vacation 🏝😁

@vobu vobu closed this as completed in #309 Jul 27, 2022
vobu pushed a commit that referenced this issue Jul 27, 2022
resolves #304 
* feat: improved error messages
- improve the error message output when trying to execute standard functions on an not found control
- move the proxy check out of the press event itself and use it in getWebElement() itself
* feat: improve fluent async api error output
- Log error when control was not found also for fluentAPI Call
* feat: add comment to better understand the coding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants