Hello Folks,

In this post, we will see an interesting scenario .

When we open a website and scroll down, suddenly a button appears, which says “Click me anytime if you want to go on top again”. An example is given below:

You need to verify functionality of Back To Top button using selenium webdriver.

We will use a JavaScript command to get scroll height. Example program is below:

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappySelenium

6 thoughts on “How To Verify Functionality Of Back To Top Button In Selenium WebDriver

  1. Good one!!

    There should be an if condition to validate whether the test was successful or not. Something like

    Assert.assertEquals(defaultScroll, currentScrollHeightAfterClickingOnBackToTop);

    then only we can say if our test was successful or not. otherwise its just scroll testing

    A suggestion could you please before the code mention steps you are going to perform. like previously you shared explanation in detail.

Leave a Reply