Handling Spinner In Selenium:
To handle Spinner in selenium we have to use Synchronization concept with the help of wait.
It is always best to use Explicit Wait on each control. so we have been using Explicit Wait in our below example.
We are handling Spinner from Spinner Link this link. Click on it.
Basically above link contains two buttons-
1- Show Spinner
2- Hide Spinner
Show Spinner: When we click "Show Spinner" button then spinner is moving with 5-second timeout once 5-Second elapsed data will be loaded in tabular format.
Hide Spinner: When we click on "Hide Spinner" button It will hide the Spinner as well as tabular data (if tabular data is present/already loaded on page)
Intention of having such scenario/example is correlating with real time scenario- where when user click on any button then data is fetching from database in mean time spinner is running on page and block the page activity once the data is ready spinner will disappear from screen.
Explicit Wait:
- WebdriverWait
- FluentWait
In example we have passed Webdriver object and By class object which is the locator path to spinner to function - waitTillSpinnerDisable(WebDriver driver, By by)
apply(): We have override apply method which will return either true or false. In example it will return TRUE in case of spinner is disappear (i.e. style.display="none") else it will return FALSE in case of timeout or style.display="block".
Once the Spinner is disappear it will load the data in tabular format and we have to parse the table where we need to select check on the basis of if Name & Surname gets matched with tabular data where we passed Name & Surname at execution time.
Execution Steps:
- Load the page
- Click on Show Spinner button
- Pass the driver object and locator for Spinner to waitTillSpinnerDisappear method
- Check the method return type if above method waitTillSpinnerDisappear return true then
- Parse the table with condition Name & Surname gets matched if match then select respective check box.
Download:
Download Spinner.html file form below link :-
or
Refer to page-
http://avinashpandeblogsonseleniumautomation.blogspot.com/2018/06/spinner-to-handle-in-selenium.html
Java Code:
I tried with the above code. It's not working for me came up with Timeout Exception Error.
ReplyDeleteEvent though the Spinner is Disabled.It have to throw true for but it's throwing Timeout Exception. Can you please help in this.
Selenium Automation Blogs By Avinash Pande: Handling Spinner In Selenium >>>>> Download Now
ReplyDelete>>>>> Download Full
Selenium Automation Blogs By Avinash Pande: Handling Spinner In Selenium >>>>> Download LINK
>>>>> Download Now
Selenium Automation Blogs By Avinash Pande: Handling Spinner In Selenium >>>>> Download Full
>>>>> Download LINK A6