2
votes

I am working with Robot FW for the first time and am facing an issue - one of the test cases requires a modal confirmation dialog to open, after which a button "Delete" is pressed. The keyword for the test case is given below:

Delete Test Data
    [Arguments]    ${name}  
    Wait Until Element Is Visible    xpath=//tr[@item_name='${name}']  
    Click Button    xpath=//tr[@item_name='${name}']//button[@class='btn btn-sm btn-danger']
    Wait Until Element Is Visible    id=deleteItem    timeout=10
    Click Button    Delete    
    Wait Until Element Is Not Visible    xpath=//tr[@item_name='${name}']

The line Wait Until Element Is Visible id=deleteItem timeout=10 is causing all the problems. Sometimes the element is visible within the time limit, at other times it is not. I increased the timeout to 10 seconds, but it does not fix the problem. How can I make the dialog appear each time without failing? Any help is appreciated, thanks!

3
Have you verified that the button is actually visible or not? Are you certain this is not a bug with the code you are testing? Do you get a screenshot when the keyword fails? Can you see the button in the screenshot?Bryan Oakley
That is the problem, the dialog box is supposed to show 3 times as a part of a loop. it shows the first time, but then hangs the 2nd time, but only sometimes.user3033194
The screenshot does not show the dialog when the test fails.user3033194
I'm not sure I understand your answer. If the screenshot does not show the dialog, and you're testing for the dialog to be visible, isn't the test behaving properly? It's saying it's not visible, and visually it's not visible?Bryan Oakley
But it is supposed to be visible. Sometimes it is, sometimes it isn't. That is causing the test to fail sometimes.user3033194

3 Answers

2
votes

My approach is to change the 'Wait Until Element is Visible' to Wait Until Page Contains Element like below..

${check_element}=  Run Keyword and Return Status   Wait Until Page Contains Element    locator    10s
Run Keyword If      '${check_element}' == 'True'     Click Element  locator

The reason to change to this keyword is that sometimes, the element is already loaded and available in DOM or page but the visibility is hidden. This intermittent weird thing happen to me some times.

0
votes

I have also faced same kind of failures.

I am able to solve this problem by using "Wait Until Keyword Succeeds" keyword.

"Wait Until Keyword Succeeds" keyword, the waited condition is checked and retried repeatedly until the condition passes or a timeout period expires.

e.g.

Wait Until Keyword Succeeds    1 min    1 sec    Element Should Be Visible    xpath=//input[@id='aName']
-2
votes

Try using Wait Until Element Is Clickable as it is a button, it should solve your issue.

so, it should be something like

Wait Until Element Is Clickable deleteItem timeout=10