How To Verify Functionality Of Back To Top Button In Selenium WebDriver

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

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

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 to Vibhor Jain Cancel reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.
%d bloggers like this: