Reputation:
I need to test the Load More button using Do-While Loop
in Robot Framework using Selenium. I don't know the syntax of do-while
so I used a common syntax in the following code.
My Sample Code Logic
do {
Run Keyword If Run Keyword And Return Status Element Should Be Visible ${PO_FieldLabel}) == FALSE FAIL Item not loaded Properly
} while (Run Keyword And Return Status Element Should Be Visible ${PO_LoadMore_Btn})
My logic is to loop the iteration till the Load More Button ${PO_LoadMore_Btn}
is exist. If exist, check the Name Field ${PO_FieldLabel}
is exist. Once the Name Field ${PO_FieldLabel}
is NOT EXIST, FAIL
the test case and skip the loop.
Upvotes: 2
Views: 8802
Reputation: 148
While loops have been added to RobotFramework 5.0
This allows you to build a DO-While structure with in infinite While loop you conditionally break.
WHILE True
# Body of your Do-While loop here
IF ${some_condition}
BREAK
END
END
Upvotes: 0
Reputation: 4875
In Robot Framework, there is NO WHILE LOOP
, DO-WHILE LOOP
. It has only FOR LOOP
We can perform the DO-WHILE LOOP
using FOR LOOP
Kindly look the following code
:FOR ${i} IN RANGE 999999
/
/ YOUR LOGIC
/
/ Exit For Loop If {bool expression}
Upvotes: 5
Reputation: 6971
In Robot Framework looping is done using the :FOR
loop construction. The Robot Framework userguide section on Loops has more information on the types of loops you can construct and the input they require.
Upvotes: 2