I am using Robot Framework,
At the moment I have 5-10 test cases and i use sleep to wait for the page to fully load after clicking a button,
*** Variables ***
${Name} = example name
${Next_Button} = xpath=//*[@id="app"]/div/div[1]/div[3]/div/div/div[1]/div[2]/div/div/div/button[2]
*** Keywords ***
Open Tab
Click Element xpath=//*[@id="app"]/div/div[1]/div[1]/div[2]/nav/ul/li[2]/a
Sleep 5s
Open Details
Click Element xpath=//*[@id="app"]/div/div[1]/div[3]/div/div/div[1]/div[2]/div/div[1]/img
sleep 5s
Navigate to Room Details
click button xpath=//*[@id="app"]/div/div[1]/div[3]/div/div/div[1]/div[2]/div/div/button
click button ${Next_Button}
click button ${Next_Button}
sleep 3s
When my tests increase to a bigger number it will take a lot of time to run them,
Whats a more efficient way of using Sleep, or a different keyword that would work for a lot of tests. My web app loads from 1-5 seconds.
Explicit sleeps generally are not very good. Instead you should use Wait Until Element Is Visible
and Wait Until Element Is Not Visible
or Wait Until Page Contains Element
and Wait Until Page Does Not Contain Element
.
Additional info: https://github.com/robotframework/HowToWriteGoodTestCases/blob/master/HowToWriteGoodTestCases.rst#avoid-sleeping
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With