How To Generate Mouse Scrolling Event Using Selenium IDE With Example Tutorial

Many tutorial post are available for selenium IDE Mouse related commands but mouse scrolling event was missing from them till now. You need mouse scrolling event when you are testing software application like Facebook. In Facebook, post are loaded on mouse scrolling if you have seen. In this kind of scenario,
you need to generate mouse scrolling event in selenium IDE.

Let me give you an example. First of all open one page which contains vertical scroll bar(long description page) and then run bellow test case in selenium IDE.

New Test
CommandTargetValue
store40i
store0looptimes
whilestoredVars.looptimes <= 20
storeEvalselenium.browserbot.
getCurrentWindow().scrollTo(0,${i})

storejavascript{storedVars.looptimes++;}
storeEval${i}+40i
endWhile


(Note : You need to attache user-extension.js file with selenium IDE to get support of "while" command in selenium IDE. Click here to view steps of downloading and installing user-extension.js file with selenium IDE.)
When you run above script in selenium IDE, it will scroll your page vertically if scroll bar is there on page.
  • You can change while loop value from '20' to your choice depending on length of page. If page is lengthy then increase that value.
  • 'selenium.browserbot.getCurrentWindow().scrollTo(0,${i})' is used with "storeEval" command for generating scroll event on page using selenium IDE. If you want to generate scroll event on horizontal scroll bar then use ''selenium.browserbot.getCurrentWindow().scrollTo(${i},0)''. It will create horizontal scrolling event on software web application page.
  • In above script you can change ${i}+40 --> ${i}+60 to increase or ${i}+40 --> ${i}+20 to decrease scrolling speed.

13 comments:

  1. Very informative

    ReplyDelete
  2. Gud one ,, thankx

    ReplyDelete
  3. How to use this on a pop up window? I have a pop up menu with scroll bar.
    what should i do?
    Please reply.
    arjunps22@gmail.com

    ReplyDelete
  4. How to use this facility on a pop up menu? I have a pop up menu with scroll bar.
    Please reply what should i do.
    arjunps22@gmail.com

    ReplyDelete
  5. when i run above test case selenium IDE troughs [error] Unknown command: 'While' above error

    ReplyDelete
    Replies
    1. Dowload the "user-extensions.js" and then in selenium IDE goto Options->Options and under the "selenium core extensions" type the path of "user-extensions.js"

      Delete
  6. hey. i am testing a website and clicking on a button, after that i get an error of "unexpected alert". Can you tell me how to handle such unexpected alerts using selenium ide?

    ReplyDelete
    Replies
    1. You can do It using storeAlertPresent and gotoif command. Send me your example link by filling form given on bellow URL.
      http://software-testing-tutorials-automation.blogspot.com/p/request-free.html.

      Delete
  7. Hey, thanks pretty much good informative blog.
    While loop command with js, it help me lot.


    ReplyDelete
  8. when i run above test case selenium IDE troughs [error] Unknown command: 'While' above error

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Hi! I tried this running the code above but my scrollbar would only move once. The loop executed without error. What could be the problem?

    ReplyDelete
  11. pls help me anyone,In my project use the two calender start date or end date but they select one calender value and calender is not close .pls tell me

    ReplyDelete