Sunday, 24 June 2018

Handling Spinner in Selenium

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:
  1. WebdriverWait
  2. FluentWait
In below example we have used fluent wait with Function which is parameter to until function.
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:
  1. Load the page
  2. Click on Show Spinner button
  3. Pass the driver object and locator for Spinner to waitTillSpinnerDisappear method
  4. Check the method return type if above method waitTillSpinnerDisappear return true then
  5. 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- 




Java Code:


2 comments:

  1. I tried with the above code. It's not working for me came up with Timeout Exception Error.
    Event though the Spinner is Disabled.It have to throw true for but it's throwing Timeout Exception. Can you please help in this.

    ReplyDelete
  2. Selenium Automation Blogs By Avinash Pande: Handling Spinner In Selenium >>>>> Download Now

    >>>>> 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

    ReplyDelete