How To Generate Mouse Scrolling Event Using Selenium IDE With Example
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 | ||
Command | Target | Value |
store | 40 | i |
store | 0 | looptimes |
while | storedVars.looptimes <= 20 | |
storeEval | selenium.browserbot.getCurrentWindow().scrollTo(0,${i}) | |
store | javascript{storedVars.looptimes++;} | |
storeEval | ${i}+40 | i |
endWhile |
(Note : You need to attache user-extension.js file with selenium IDE to get support of "while" command in selenium IDE.
When you run above script in selenium IDE, it will scroll your page vertically if scroll bar is there on page.
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.
steps of downloading and installing user-extension.js file with selenium IDE
here are couple of advanced options available in selenium IDE like increasing timeout, attaching user extensions, attaching data file, and few other. Let describe here couple of them for your reference.
To open selenium IDE option window, Click on Options > Options from main menu. It will open option
window as shown in bellow figure. Click on General tab.
Changing Default timeout in Selenium IDE
Look into above image, there is one text box with label "Default timeout value of recorded command in milliseconds". You can change default timeout value from that text box. By default, it will be 30000 milliseconds. Default timeout value affects on execution of selenium IDE script. Suppose you set 50000 milliseconds then during execution, every command can take maximum 50000 milliseconds for execution. If command can not complete execution in given time then selenium IDE will return error like "[error] Timed out after 30000 ms".
Attaching user extensions with selenium IDE
You can extend selenium IDE function by attaching your own made extensions(Only in .js format) as per your requirement. You can attach your extension in "Selenium Core extensions (user-extensions.js)" field.Simply click on browse button to select your user extension. You can attach multiple user extension files over there.
Click here to download user extension file for "while", "endWhile", "gotoIf", "gotoLabel" and "push" commands.
(Note : Don't forget to restart selenium IDE after attaching user extension otherwise it will not affect and work)
Attaching data file with selenium IDE
There is one another field with name "Selenium IDE Extensions". Here you can attach data file(only in .js format)
(Note : Don't forget to restart selenium IDE after attaching data file otherwise it will not affect and work)
Remember Base URL
Used for remember last base URL. If selected then it will remember base URL which was used last time and appear in base URL field when you open selenium IDE window. If not selected then it will display blank when you open Selenium IDE.
Record assertTitle automatically
If selected, When you will navigate from one page to another page, Selenium IDE will add "assertTitle" command in your script during recording of selenium script.
Record absolute URL
If selected, Selenium will record absolute URL(with http: or https: Protocol) during recording.
Start recording immediately on open
If selected, selenium will start recording of script as soon as you open selenium IDE.
To open selenium IDE option window, Click on Options > Options from main menu. It will open option
window as shown in bellow figure. Click on General tab.
Changing Default timeout in Selenium IDE
Look into above image, there is one text box with label "Default timeout value of recorded command in milliseconds". You can change default timeout value from that text box. By default, it will be 30000 milliseconds. Default timeout value affects on execution of selenium IDE script. Suppose you set 50000 milliseconds then during execution, every command can take maximum 50000 milliseconds for execution. If command can not complete execution in given time then selenium IDE will return error like "[error] Timed out after 30000 ms".
Attaching user extensions with selenium IDE
You can extend selenium IDE function by attaching your own made extensions(Only in .js format) as per your requirement. You can attach your extension in "Selenium Core extensions (user-extensions.js)" field.Simply click on browse button to select your user extension. You can attach multiple user extension files over there.
Click here to download user extension file for "while", "endWhile", "gotoIf", "gotoLabel" and "push" commands.
(Note : Don't forget to restart selenium IDE after attaching user extension otherwise it will not affect and work)
Attaching data file with selenium IDE
There is one another field with name "Selenium IDE Extensions". Here you can attach data file(only in .js format)
(Note : Don't forget to restart selenium IDE after attaching data file otherwise it will not affect and work)
Remember Base URL
Used for remember last base URL. If selected then it will remember base URL which was used last time and appear in base URL field when you open selenium IDE window. If not selected then it will display blank when you open Selenium IDE.
Record assertTitle automatically
If selected, When you will navigate from one page to another page, Selenium IDE will add "assertTitle" command in your script during recording of selenium script.
Record absolute URL
If selected, Selenium will record absolute URL(with http: or https: Protocol) during recording.
Start recording immediately on open
If selected, selenium will start recording of script as soon as you open selenium IDE.
_______________________________________________________________________
Selenium IDE "focus" and "keyUp" commands with example
"focus" Command in Selenium IDE
"focus" is useful to set focus on targeted fields. Generally it is used with input fields like text box, text area, radio button, check box, button etc.. It will simply move cursor on targeted element or field.
Selenium "keyUp" Command
works in that case you can try combination of "keyDown" and "keyUp" command. "keyPress" works as user pressing and releasing a key while "keyDown" simulates a user pressing a key and "keyUp" for user releasing a key. In this way "keyPress" command = "keyDown" + "keyUp" commands.
Let we look "focus", "keyDown" and "keyUp" command with example.
New Test | ||
Command | Target | Value |
open | http://only-testing-blog.blogspot.in/p/blog-page.html | |
focus | //input[@id='group_515952624_1'] | |
keyDown | //input[@id='group_515952624_1'] | \32 |
pause | 5000 | |
keyUp | //input[@id='group_515952624_1'] | \32 |
Above example will just select "Please be agree to publish your topic on our blog" check box and you can do it simply with "click" or "select" command but here my concern is to showing you an example of "focus" "keyDown" and "keyUp" commands.
- 2nd command "focus" will set focus on "Please be agree to publish your topic on our blog" check box.
- 3rd command, will press and hold 'space' key of keyboard.
- 5th command will release 'space' key of keyboard.
Here, "keyPress" command is not working(you can try it) so that i used "keyDown" + "keyUp" commands as an alternate of "keyPress" command.
Selenium "shiftKeyDown" and "shiftKeyUp" commands example to press shift key
"shiftKeyDown" and "shiftKeyUp" commands are specially designed for shift key of keyboard. Selenium IDE has many commands related to keyboard keys(Example : keyDown) and mouse keys (Example :mouseDown). "shiftKeyDown" and "shiftKeyUp" has not major function but sometimes such specially
designed commands are very helpful in automation tools to automate your regression process easy and smooth.
Using "shiftKeyDown" Command
You can understand "shiftKeyDown" command's function from its name. It works like user is pressing and holding shift key of keyboard. Shift key not released until "shiftKeyUp" command executed.
Selenium IDE "shiftKeyUp" Command
"shiftKeyUp" command is useful to release pressed key through "shiftKeyDown" command. Bellow given example described both command's function very clearly.
New Test | ||
Command | Target | Value |
open | http://www.google.com | |
shiftKeyDown | ||
type | //input[@id='gbqfq'] | hello friends |
click | //button[@id='gbqfb'] | |
pause | 3000 | |
shiftKeyUp | ||
type | //input[@id='gbqfq'] | hello friends |
click | //button[@id='gbqfb'] |
In above example, 1st "type" command will type word "HELLO FRIENDS" (in capital letter because shift key is pressed using "shiftKeyDown") in Google search box. 2nd type command will type "hello friends" in small letter because now shift key is released using "shiftKeyUp" in previous command.
________________________________________________________________
No comments:
Post a Comment