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

cannot handle pop up window #42

Closed
Bhavnasewani opened this issue Oct 19, 2021 · 3 comments · Fixed by #52
Closed

cannot handle pop up window #42

Bhavnasewani opened this issue Oct 19, 2021 · 3 comments · Fixed by #52
Assignees
Labels
bug Something isn't working

Comments

@Bhavnasewani
Copy link

Describe the bug
I have a desktop application screen that throws an error when you dont provide data as expected, unfortunately I dont see an automation id for this screen but I do see automation Id for a OK button on it.
I want to check in my script if this error pop up occured and I want to fail the test case in case of wrong data. If provided with correct data the pop up wont show and test cases should continue.

I tried 3 keywords:
Is Element Enabled //[@AutomationId='OkButton']
Element should not be Visible //[@AutomationId='OkButton']
Element should not Exist //*[@AutomationId='OkButton']

It does executes well is there is an error pop up coming up but when the data is clean the code fails throwing error Xpath not found or it would hang the project in pycharm and would work only when I restart everything

Code snippets
${ISErrPopupVisible} Is Element Enabled //*[@AutomationId='OkButton']

IF '${ISErrPopupVisible}'=='True'
Fail There is an issue with Input Data
ELSE
Log You have input correct data, please wait for the ouput to be generated
END

@Nepitwin
Copy link
Member

Hi @Bhavnasewani

i see the issue for this checkup keywords.

All checkup keyword should return False if an Element does not Exists or the condition is false.
But in the current implementation all keywords throws an FlaUI Exception and breaks the tests for an element not found error message. It should be in this type of keywords of course FALSE return

This is only for the keyword handling by Is Keyword the case.

I will rework on this type of keywords and change the handling.

By the current status you can use a combination from core keywords by robotframework to get the correct status

https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run Keyword And Return Status

Run Keyword And Return Status

@Nepitwin Nepitwin self-assigned this Dec 15, 2021
@Nepitwin Nepitwin added the bug Something isn't working label Dec 15, 2021
Nepitwin added a commit that referenced this issue Dec 15, 2021
Extend tests to verify bugfix
Nepitwin added a commit that referenced this issue Jan 28, 2022
Extend tests to verify bugfix
Nepitwin added a commit that referenced this issue Jan 29, 2022
Extend tests to verify bugfix
@Nepitwin
Copy link
Member

Nepitwin commented Jan 29, 2022

@Bhavnasewani

Sorry for the late request. I started to reevaluate your issue.

What you want to check is that an error popup is showing if input data is wrong.

Here we got now an issue on robotframework 4. The xpath does not exists and all keywords work like expected that they fail on your side because they can not verify your respose.

Your approaches are right. You have to combine them with Keyword And Return Status

${result}  Keyword And Return Status  Element Should Not Exist //*[@AutomationId='OkButton']
IF ${result}==${False}
    Log You have input correct data, please wait for the ouput to be generated
ELSE
    ${element_exists}  Element Should Not Exist //[@AutomationId='OkButton']
    IF ${element_exists}==${True}
      Fail There is an issue with Input Data
    ELSE
      Log You have input correct data, please wait for the ouput to be generated
    END
END

By this combination you should checkup the input data and result.
If the element will be found this keyword returns True because this does not fail.
But you got know an issue, if this value will be return true you don't know if element does not exists or not? You only know that the operation was successfully. So you have to reevaluate that the element does not exists.

If it's failed because the xpath is not found because no error message popup it returns False so your input data is correct them.

The issue is here that the result is not a simple bool anymore because you have three states (Element does not exists (True) | Element exists (True) | Xpath not found (Error)

It's not a good design to combine error statements with return logic.
Robotframework 4 does not support like TRY EXCEPT usage but in Robotframework 5 it's a new feature.

What you want is similar code :

TRY
    ${element_not_exists}  Element Should Not Exist //[@AutomationId='OkButton']
    IF ${element_not_exists}==${False}
      Fail There is an issue with Input Data
    ELSE
      Log You have input correct data, please wait for the ouput to be generated
    END
EXCEPT    Error XPath Not Found
    Log  You have input correct data, please wait for the ouput to be generated
END

This syntax will be available in robotframework 5 and i will extend the error handling by these exception blocks to create such a code on your test script for a better readablity.

#47

@Nepitwin
Copy link
Member

Nepitwin commented Jan 29, 2022

In upcoming release:

New Syntax

  • You can now decide to use the old syntax or new style by using the flag parameter use_exceptions.
  • This is by default ${TRUE} to avoid this breaks for checkups if a ui element is displaying delayed.
# This throws a flaui exception and stop test exeuction
Element Should Exist      /WRONG/XPATH
Element Should Not Exist  /VALID_XPATH

# Usage with Wait Until Keyword Succeeds
Wait Until Keyword Succeeds  Element Should Exist      /VALID_XPATH
Wait Until Keyword Succeeds  Element Should Not Exist  /VALID_XPATH

# If you want to check the return value by your own syntax.
# Wait Until Keyword Succeeds will not work anymore because this keyword will always Return True or False now
${RESULT}  Element Should Exist  /VALID_XPATH  ${FALSE}
${RESULT}  Element Should Not Exist  /WRONG/XPATH  ${FALSE}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants