Monday, September 7, 2015

Selenium IDE Sample Script With Most Commonly Used Commands

In this post, I've tried to cover the most common actions that a QA performed so often while Web testing. General actions are: type, click on links, select dropdown option, multi-select, checking radio buttons and check boxes, uploading files and clicking on buttons, moving backward and scrolling. Above mentioned actions cover 90% of our testing. And it's fortunate to have Selenium IDE supports all these actions.



Here is a description of the most commonly used commands for Selenium IDE:

CommandsDescription
openTo open URL
setTimeoutSetting Timeout Limit
windowMaximizeFor Window Maximizing
storeStoring value in variable
echoTo print/log custom messages in console
clickAndWaitClicking on link
goBackAndWaitTo navigate backwards
typeTo enter values in a text field
storeEvalExecuting Javascript / Scroll
clickChecking Radio Button / Check box
selectTo Select dropdown option
addSelectionFor multiple selection boxes
assertTitleTo verify title


Below is the script in tabular form which is covering all the above listed actions with logging (have tried to implement low level logging):


Complete Practise Form:
http://www.toolsqa.com/automation-practice-form/
CommandTargetValue
open/automation-practice-form/
setTimeout10000
windowMaximize
storeSelenium Tutorials | Demo Form for practicing Selenium AutomationEXPECTED_PAGE_TITLE
echo"####### Clicking Link ########"
clickAndWaitlink=Link Test
echo"###### Using goBack command to navigate to previous page ######"
goBackAndWait
echo"###### Typing First Name and Last Name ######"
typename=firstnameDustin
typename=lastnameTaylor
echo####### Performing Scroll Action #########
storeEvalselenium.browserbot.getCurrentWindow().scrollTo(0,600)
echo"###### Check Radio Buttons & Check boxes #######"
clickid=sex-1
clickid=exp-3
clickid=profession-1
clickid=tool-1
echo"####### Performing File Upload Action #######
typeid=photoC:\Users\admin\Desktop\pic.jpg
echo####### Performing Scroll Action #########
storeEvalselenium.browserbot.getCurrentWindow().scrollTo(0,1000)
echo"####### Performing Select & Multi-Select Actions ########"
selectid=continentslabel=Australia
addSelectionid=selenium_commandslabel=Navigation Commands
addSelectionid=selenium_commandslabel=Switch Commands
clickAndWaitid=submit
echo${EXPECTED_PAGE_TITLE}
assertTitle${EXPECTED_PAGE_TITLE}
echo"###### PASSED - Test Completed Successfully #######"


See you soon with some new posts on automation.

Till then keep Rocking Folks ..!!

Happy Learning :)



@uthor
Vaneesh Behl