Sunday, 6 April 2014

Selenium IDE Questions & Answers

Question 1:
What are two modes of views in Selenium IDE?
Answer:
Selenium IDE can be opened either in side bar (View > Side bar > Selenium IDE) or as a pop up window (Tools > Selenium IDE). While using Selenium IDE in browser side bar it cannot record user operations in a pop up window opened by application.

Question 2:
Can I control the speed and pause test execution in Selenium IDE?
Answer:
Selenium IDE provides a slider with Slow and Fast pointers to control the speed of execution.

Question 3:
Where do I see the results of Test Execution in Selenium IDE?
Answer:
Result of test execution can be views in log window in Selenium IDE –

Question 4:
Where do I see the description of commands used in Selenium IDE?
Answer:
Commands of description can be seen in Reference section –

Question 5:
Can I build test suite using Selenium IDE?
Answer:
Yes, you can first record individual test cases and then group all of them in a test suite. Following this entire test suite could be executed instead of executing individual tests.

Question 6:
What verification points are available with Selenium?
Answer:
There are largely three type of verification points available with Selenium –
·         Check for page title
·         Check for certain text
·         Check for certain element (text box, drop down, table etc)

Question 7:
I see two types of check with Selenium – verification and assertion, what’s the difference between tow?
Answer:
A verification check lets test execution continue even in the wake of failure with check, while assertion stops the test execution. Consider an example of checking text on page, you may like to use verification point and let test execution continue even if text is not present. But for a login page, you would like to add assertion for presence of text box login as it does not make sense continuing with test execution if login text box is not present.

Question 8:
I don’t see check points added to my tests while using Selenium IDEL, how do I get them added to my tests?
Answer:
You need to use context menu to add check points to your Selenium IDE tests –

Question 9:
How do I edit tests in Selenium IDE?
Answer:
There are two ways to edit tests in Selenium IDE; one is the table view while other looking into the source code of recorded commands –

Question 10:
What is syntax of command used in Selenium?
Answer:
There are three entities associated with a command –
·         Name of Command
·         Element Locator (also known as Target)
·         Value (required when using echo, wait etc)

Question 11:
There are tons of Selenium Command, am I going to use all of them
Answer:
This entirely boils down to operations you are carrying out with Selenium. Though you would definitely be using following Selenium Commands more often –
·         Open: opens a web page.
·         click/clickAndWait: click on an element and waits for a new page to load.
·         Select: Selects a value from a drop down value.
·         verifyTitle/assertTitle: verifies/asserts page title.
·         verify/assert ElementPresent: verifies/asserts presence of element, in the page.
·         verify/assert TextPresent verifies/asserts expected text is somewhere on the page.

Question 12:
How do I use html id and name while using Selenium IDE
Answer:
Html id and name can be used as it is in selenium IDE. For example Google search box has name – “q” and id – “list-b” and they can be used as target in selenium IDE –

Question 13:
What is XPath? When would I have to use XPath in Selenium IDE?
Answer:
XPath is a way to navigate in xml document and this can be used to identify elements in a web page. You may have to use XPath when there is no name/id associated with element on page or only partial part of name/ide is constant.
Direct child is denoted with - /
Relative child is denoted with - //
Id, class, names can also be used with XPath –
·         //input[@name=’q’]
·         //input[@id=’lst-ib’]
·         //input[@class=’ lst’]
·         If only part of id/name/class is constant than “contains” can be used as –
·         //input[contains(@id,'lst-ib')]

Question 14:
What is CSS location strategy in Selenium?
Answer:

CSS location strategy can be used with Selenium to locate elements, it works using cascade style sheet location methods in which -
Direct child is denoted with – (a space)
Relative child is denoted with - >
Id, class, names can also be used with XPath –
·         css=input[name=’q’]
·         css=input[id=’lst-ib’] or input#lst-ib
·         css=input[class=’ lst’] or input.lst
·         If only part of id/name/class is constant than “contains” can be used as –
·         css=input[id*=' lst-ib ')]
·         Element location strategy using inner text
·         css = a:contains(‘log out’)

Question 15:
There is id, name, XPath, CSS locator, which one should I use?
Answer:
If there are constant name/id available than they should be used instead of XPath and CSS locators. If not then css locators should be given preference as their evaluation is faster than XPath in most modern browsers.
Question 16: 
I want to generate random numbers, dates as my test data, how do I do this in Selenium IDE? 
Answer: 
This can be achieved by executing java script in Selenium. Java script can be executed using following syntax –
type
css=input#s
javascript{Math.random()}

And for date –
type
css=input#s
javascript{new Date()}

Question 17:
Can I store result of an evaluation and use it later in my test?
Answer:
You can use “store” command to achieve this. You can save result of an evaluation in a variable and use it later in your Selenium IDE script. For example we can store value from a text box as following, and later use it to type it in another text box –
storeText
css=input#s
var1
type
css=input#d
${var1}

Question 18:
I have stored result of an evaluation; can I print it in IDE to check its value?
Answer:
You can use echo command as following to check the stored value in Selenium IDE –

storeText
css=input#s
var1
echo
${var1}

Question 19:
Can I handle java script alert using Selenium?
Answer
You could use verify/assertAlert to check presence of alert on page. Since selenium cannot click on “Ok” button on js alert window, the alert itself does not appear on page when this check is carried out.

Question 20:
Selenium has recorded my test using XPath, how do I change them to css locator?
Answer
You can use drop down available next to Find in Selenium to change element locator used by Selenium –

Question 21:
I have written my own element locator, how do I test it?
Answer
You can use Find button of Selenium IDE to test your locator. Once you click on it, you would see element being highlighted on screen provided your element locator is right Else one error message would be displayed in log window.

Question 22:
I have written one js extension; can I plug it in Selenium and use it?
Answer
You could specify you js extension in “Options” window of Selenium IDE –

Question 23:
How do I convert my Selenium IDE tests from Selenese to another language?
Answer
You could use Format option of Selenium IDE to convert tests in another programming language –

Question 24:
I have converted my Selenium IDE tests to java but I am not able to execute themL, execution options as well as Table tab of Selenium IDE is disabledLL
Answer
This is because Selenium IDE does not support execution of test in any other language than Selenese (language of Selenium IDE). You can convert Selenium IDE in a language of your choice and then use Selenium 1.0 to execute these tests in that language.

Question 25:
I want to use only Selenese as my test script language but still want to execute tests in other browsers, how do I do that?
Answer
You can execute you Selenese test in another browser by specifying the “-htmlSuite” followed by path of your Selenese suite while starting the Selenium Server. Selenium Server would be covered in details in question about Selenium RC.

Question 26:
I have added one command in middle of list of commands, how do I test only this new command?
Answer
You can double click on newly added command and Selenium IDE would execute only that command in browser.

Question 27:
Can I make Selenium IDE tests begin test execution from a certain command and not from the very first command?
Answer
You could set a command as “start” command from context menu. When a command is set as start command then a small green symbol appears before command. Same context menu can be used to toggle this optio

Question 28:
Are there other tools available outside Selenium IDE to help me tests my element locators
Answer
You could XPath checker - https://addons.mozilla.org/en-US/firefox/addon/xpath-checker/ to test you XPath locators and Firefinder (a firebug add on) to test you css locators –
https://addons.mozilla.org/en-US/firefox/addon/firefinder-for-firebug/
Firefinder can also be used to test XPath locators.

Question 29:
What is upcoming advancement in Selenium IDE?
Answer
The latest advancement in Selenium IDE would be to have capabilities of converting Selenium IDE tests in Webdriver (Selenium 2.0) options. This would help generating quick and dirty tests for Selenium 2.0

Question 30:
How can I use looping option (flow control) is Selenium IDE
Answer
Selenese does not provide support for looping, but there is extension which could be used to achieve same. This extension can be download from here - http://51elliot.blogspot.com/2008/02/selenium-ide-goto.html
This extension can be added under “Selenium IDE Extension” section to use loop feature in Selenium IDE.

Question 31:Can I use screen coordinate while using click command? I want to click at specific part of my element.
 
Answer 
You would need to use clickAT command to achieve. clickAt command accepts element locator and x, y coordinates as arguments –
clickAt(locator, coordString)

Question 32:
How do I verify presence of drop down options using Selenium?
Answer
Use assertSelectOptions as following to check options in a drop down list –
assertSelectOptions

Question 33:
Can I get data from a specific html table cell using Selenium IDE?
Answer
Use storeTable command to get data from a specific cell in an html table, following example store text from cell 0,4 from an html table –
storeTable
css=#tableId.0.4
textFromCell

Question 34:
I want to make Selenium IDE record and display css locator followed by other locators, is it possible to give high priority to css locator in Selenium IDE?
Answer
You can change default behavior of Selenium IDE > element locator preference by crating js file with following–
LocatorBuilders.order = ['css:name', 'css:id', 'id', 'link', 'name', 'xpath:attributes'];

And add this file under “Selenium IDE Extension” under Selenium Options.

Question 35:
My application has dynamic alerts which don’t always appear, how do I handle them?
Answer
If you want to simulate clicking “ok “ on alert than use – chooseOkOnNextConfirmation and if you want to simulate clicking “cancel” on alert than use - chooseCancelOnNextConfirmation ( )

Question 36:
Can I right click on a locator?
Answer
You can use command - contextMenu ( locator) to simulate right click on an element in web page.

Question 37:
How do I capture screen shot of page using Selenium IDE?
Answer
Use command – captureEntirePageScreenshot to take screen shot of page.

Question 38:
I want to pause my test execution after certain command.
Answer
Use pause command which takes time in milliseconds and would pause test execution for specified time – pause ( waitTime )

Question 39:
I used open command to launch my page, but I encountered time out errorL
Answer
This happens because open commands waits for only 30 seconds for page to load. If you application takes more than 30 sec then you can use “setTimeout ( timeout )” to make selenium IDE wait for specified time, before proceeding with test execution.

Question 40:
What’s the difference between type and typeKeys commands?
Answer
type command simulates enter operations at one go while typeKeys simulates keystroke key by key.
typeKeys could be used when typing data in text box which bring options (like Google suggestion list) because such operation are not usually simulated using type command.

No comments:

Post a Comment