Q.1.What is Selenium?
Selenium is software which contains some
set of programs
Selenium components:
Selenium IDE: it is set of programs + a user
interface from where the user can interact with that set of programs.
Advantages:
v
Free software
v
Easy to install
v
Its
main feature is record and playback
v
Scripts recorded in IDE can be converted into other language like
Java, C#, Python and Ruby
v
It is not only a time saver but
also an excellent way of Learning scripts syntax
v
We can insert comments, commands
Disadvantages:
Main
disadvantage of IDE is that it runs only in Firefox
Browser
v We can’t write the script manually
v Cannot upload files
v It does not directly support loops and
conditions
v Reading from external files like .txt,
.xls is not possible
v We can perform very limited testing
Selenium RC (remote control): it is a set of programs to perform automation testing, to interact with
those programs we need to configure them in any user interface. Generally
people use eclipse as it is a powerful editor for writing java programs.
Note: after selenium rc they have made selenium web driver as more powerful.
Selenium web driver is providing more facilities for automation testing when
compare to RC people started using web driver and slowly RC is getting
deprecated.
Disadvantages:
v
There are
very limited features in RC when working with Ajax based UI elements
v
we need to
start, stop the server manually
v
Controlling
multiple windows is somewhat difficult
Selenium web driver: it is a set of powerful programs to perform automation testing, to
interact with those programs we need to configure them in any user interface.
Generally people use eclipse for configuring the web driver programs
into eclipse
Eclipse is a powerful editor for writing the java
programs.
Advantages;
1)
Support for iPhone and Android testing
2)
Implementation of listeners - a much awaited feature
3)
Better features for Ajax
testing.
4)
You can easily simulate clicking on front and back button of
browser.
5)
You can extract objects in bulk like QTP. For ex - extract all
links of page. With RC this was a big hastle
6)
Unlike RC you don’t have to start a server in web driver.
7)
You can simulate movement of a mouse using selenium.
8)
) Tabs and pops are more or less the same. RC can also handle and
Web driver can also handle.
9)
You can find coordinates of any object using Web driver.
10)
You have classes in Web driver which help you to simulate key
press events of keyboard.
11)
Keyword driven framework is very easy to build in web driver.
Selenium grid: it is a set of programs used for
executing the tests parallel on multiple machines in order to increase the
performance of execution.
SELENIUM
GRID Advantages
v Remote Execution of the selenium tests can be done using Selenium Grid without
actually copying your test code to remote system.
v Selenium Grid can be used to save time by executing
Independent test cases in parallel.
v Load Testing can be done if we register a lot of remote control to a
single hub and execute test case in parallel to simulate multiple transactions
at a single time period.
Q2. What
are the main components of Selenium testing tools?
Selenium IDE, Selenium RC and Selenium Grid
Q3. What is Selenium IDE?
Selenium IDE is for building Selenium test cases. It operates as a Mozilla Firefox add on and provides an easy to use interface for developing and running individual test cases or entire test suites. Selenium-IDE has a recording feature, which will keep account of user actions as they are
performed and store them as a reusable script to play back.
Q4. What is the use of context menu in Selenium IDE?
It allows the user to pick from a list of assertions and verifications for the selected location.
Q5. Can tests recorded using Selenium IDE be run in other browsers?
Yes. Although Selenium IDE is a Firefox add on, however, tests created in it can also be run in other browsers by using Selenium RC (Selenium Remote Control) and specifying the name of the test suite in command line.
Q6. What are the advantage and features of Selenium IDE?
1. Intelligent field selection will use IDs, names, or XPath as needed
2. It is a record & playback tool and the script format can be written in various languages including C#, Java, PERL, Python, PHP, HTML
3. Auto complete for all common Selenium commands
4. Debug and set breakpoints
5. Option to automatically assert the title of every page
6. Support for Selenium user-extensions.js file
Q7. What are the disadvantage of Selenium IDE tool?
1. Selenium IDE tool can only be used in Mozilla Firefox browser.
2. It is not playing multiple windows when we record it.
Q8. What is Selenium RC (Remote Control)?
Selenium RC allows the test automation expert to use a programming language for maximum flexibility and extensibility in developing test logic. For example, if the application under test returns a result set and the automated test program needs to run tests on each element in the result set, the iteration / loop support of programming language’s can be used to iterate through the result set, calling Selenium commands to run tests on each item.
Selenium RC provides an API and library for each of its supported languages. This ability to use Selenium RC with a high level programming language to develop test cases also allows the automated testing to be integrated with the project’s automated build environment.
Q9. What is Selenium Grid?
Selenium Grid in the selenium testing suit allows the Selenium RC solution to scale for test suites that must be run in multiple environments. Selenium Grid can be used to run multiple instances of Selenium RC on various operating system and browser configurations.
Q10. How Selenium Grid works?
Selenium Grid sent the tests to the hub. Then tests are redirected to an available Selenium RC, which launch the browser and run the test. Thus, it allows for running tests in parallel with the entire test suite.
Q 11. What you say about the flexibility of Selenium test suite?
Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium framework to customize test automation. As compared to other test automation tools, it is Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming and
scripting languages allows the test automation engineer to build any logic they need into their automated testing and to use a preferred programming or scripting language of one’s choice. Also, the Selenium testing suite is an open source project where code can be modified and enhancements can be submitted for contribution.
Q12. What test can Selenium do?
Selenium is basically used for the functional testing of web based applications. It can be used for testing in the continuous integration environment. It is also useful for agile testing
Q13. What is the cost of Selenium test suite?
Selenium test suite a set of open source software tool, it is free of cost.
Q14. What browsers are supported by Selenium Remote Control?
Selenium IDE, Selenium RC and Selenium Grid
Q3. What is Selenium IDE?
Selenium IDE is for building Selenium test cases. It operates as a Mozilla Firefox add on and provides an easy to use interface for developing and running individual test cases or entire test suites. Selenium-IDE has a recording feature, which will keep account of user actions as they are
performed and store them as a reusable script to play back.
Q4. What is the use of context menu in Selenium IDE?
It allows the user to pick from a list of assertions and verifications for the selected location.
Q5. Can tests recorded using Selenium IDE be run in other browsers?
Yes. Although Selenium IDE is a Firefox add on, however, tests created in it can also be run in other browsers by using Selenium RC (Selenium Remote Control) and specifying the name of the test suite in command line.
Q6. What are the advantage and features of Selenium IDE?
1. Intelligent field selection will use IDs, names, or XPath as needed
2. It is a record & playback tool and the script format can be written in various languages including C#, Java, PERL, Python, PHP, HTML
3. Auto complete for all common Selenium commands
4. Debug and set breakpoints
5. Option to automatically assert the title of every page
6. Support for Selenium user-extensions.js file
Q7. What are the disadvantage of Selenium IDE tool?
1. Selenium IDE tool can only be used in Mozilla Firefox browser.
2. It is not playing multiple windows when we record it.
Q8. What is Selenium RC (Remote Control)?
Selenium RC allows the test automation expert to use a programming language for maximum flexibility and extensibility in developing test logic. For example, if the application under test returns a result set and the automated test program needs to run tests on each element in the result set, the iteration / loop support of programming language’s can be used to iterate through the result set, calling Selenium commands to run tests on each item.
Selenium RC provides an API and library for each of its supported languages. This ability to use Selenium RC with a high level programming language to develop test cases also allows the automated testing to be integrated with the project’s automated build environment.
Q9. What is Selenium Grid?
Selenium Grid in the selenium testing suit allows the Selenium RC solution to scale for test suites that must be run in multiple environments. Selenium Grid can be used to run multiple instances of Selenium RC on various operating system and browser configurations.
Q10. How Selenium Grid works?
Selenium Grid sent the tests to the hub. Then tests are redirected to an available Selenium RC, which launch the browser and run the test. Thus, it allows for running tests in parallel with the entire test suite.
Q 11. What you say about the flexibility of Selenium test suite?
Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium framework to customize test automation. As compared to other test automation tools, it is Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming and
scripting languages allows the test automation engineer to build any logic they need into their automated testing and to use a preferred programming or scripting language of one’s choice. Also, the Selenium testing suite is an open source project where code can be modified and enhancements can be submitted for contribution.
Q12. What test can Selenium do?
Selenium is basically used for the functional testing of web based applications. It can be used for testing in the continuous integration environment. It is also useful for agile testing
Q13. What is the cost of Selenium test suite?
Selenium test suite a set of open source software tool, it is free of cost.
Q14. What browsers are supported by Selenium Remote Control?
The
test automation expert can use Firefox, IE 7/8, Safari and Opera browsers to
run tests in Selenium Remote Control.
Q15. What programming languages can you use in Selenium RC?
C#, Java, Perl, PHP, Python, Ruby
Q16. What are the advantages and disadvantages of using Selenium as testing tool?
Q15. What programming languages can you use in Selenium RC?
C#, Java, Perl, PHP, Python, Ruby
Q16. What are the advantages and disadvantages of using Selenium as testing tool?
Advantages:
Free, Simple and powerful DOM (document object model) level testing, can be
used for continuous integration; great fit with Agile projects.
Disadvantages: Tricky setup; dreary errors diagnosis; cannot test client server applications.
Q17. What is difference between QTP and Selenium?
Only web applications can be testing using Selenium testing suite. However, QTP can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, QTP is limited to
Internet Explorer on Windows.
QTP uses scripting language implemented on top of VB Script. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.
Q18. What is difference between Borland Silk test and Selenium?
Ans. Selenium is completely free test automation tool, while Silk Test is not. Only web applications can be testing using Selenium testing suite. However, Silk Test can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, Silk Test is limited to Internet Explorer and Firefox.
Disadvantages: Tricky setup; dreary errors diagnosis; cannot test client server applications.
Q17. What is difference between QTP and Selenium?
Only web applications can be testing using Selenium testing suite. However, QTP can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, QTP is limited to
Internet Explorer on Windows.
QTP uses scripting language implemented on top of VB Script. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.
Q18. What is difference between Borland Silk test and Selenium?
Ans. Selenium is completely free test automation tool, while Silk Test is not. Only web applications can be testing using Selenium testing suite. However, Silk Test can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, Silk Test is limited to Internet Explorer and Firefox.
Selenium
is a software which contains some set of
programmes
Q.19.How is Selenium
different from commercial browser automation tools?
Selenium is a library which is
available in a gamut of languages i.e. java, C#, pearl, python, ruby, php etc
while most commercial tools are limited in their capabilities of being able to
use just one language. More over many of those tools have their own proprietary
language which is of little use outside the domain of those tools. Most
commercial tools focus on record and replay while Selenium emphasis on using
Selenium IDE (Selenium record and replay) tool only to get acquainted with
Selenium working and then move on to more mature Selenium libraries like Remote
control (Selenium 1.0) and Web Driver (Selenium 2.0).Though most commercial
tools have built in capabilities of test reporting, error recovery mechanisms
and Selenium does not provide any such features by default. But given the rich
set of languages available with Selenium it very easy to emulate such features.
Q.20.What are the set
of tools available with Selenium?
Selenium has four set of tools – Selenium IDE, Selenium 1.0 (Selenium
RC), Selenium 2.0 (WebDriver) and Selenium Grid. Selenium Core is another tool
but since it is available as part of Selenium IDE as well as Selenium 1.0, it
is not used in isolation.
Q.21.Which Selenium
Tool should I use?
It entirely boils down to where you stand today in terms of using
Selenium. If you are entirely new to Selenium then you should begin with Selenium
IDE to learn Selenium location strategies and then move to Selenium 2 as it is
the most stable Selenium library and future of Selenium. Use Selenium Grid when
you want to distribute your test across multiple devices. If you are already
using Selenium 1.0 than you should begin to migrate your test scripts to Selenium
2.0
Q.22.What is Selenium
IDE?
Selenium IDE is a Firefox plug-in which
is (by and large) used to record and replay test is Firefox browser. Selenium
IDE can be used only with Firefox browser.
Q.23.Which language
is used in Selenium IDE?
Selenium IDE uses html sort of language
called Selenese. Though other languages (java, c#, php etc) cannot be used with Selenium IDE, Selenium IDE lets you
convert test in these languages so that they could be used with Selenium 1.0 or
Selenium 2.0
Q.24.What is Selenium
1.0?
Selenium 1.0 or Selenium Remote Control
(popularly known as Selenium RC) is library available in wide variety of
languages. The primary reason of advent of Selenium RC was incapability of
Selenium IDE to execute tests in browser other than Selenium IDE and the programmatically
limitations of language Selenese used in Selenium IDE.
Q.25. What is
Selenium 2.0?
Selenium 2.0 also known as Web Driver
is the latest offering of Selenium. It provides · better API than
Selenium 1.0
·Does not suffer from java script
security restriction which Selenium 1.0 does · supports more UI
complicated UI operations like drag and drop
Q.26.What are the
element locators available with Selenium which could be used to locate elements
on web page?
There
are mainly 4 locators used with Selenium –
·html id
·html name
·XPath locator and
·Css locators
Q.27.What is Selenium
Grid?
Selenium grid lets you distribute your
tests on multiple machines and all of them at the same time. Hence you can
execute test on IE on Windows and Safari on Mac machine using the same test
script (well, almost always). This greatly helps in reducing the time of test
execution and provides quick feedback to stack holders.
Q.28.What are two
modes of views in Selenium IDE?
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.
Q.29.Can I control
the speed and pause test execution in Selenium IDE?
Selenium IDE provides a slider with Slow
and Fast pointers to control the speed of execution.
Q.30.Where do I see
the results of Test Execution in Selenium IDE?
Result of test execution can be viewed
in log window in Selenium IDE
Q.31.Where do I see
the description of commands used in Selenium IDE?
Commands of description can be seen in
Reference section
Q.32.Can I build test
suite using Selenium IDE?
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.
Q.33.What
verification points are available with Selenium?
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)
Q.34.I see two types
of check with Selenium – verification and assertion, what’s the difference
between tow?
· 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.
Q.35.I don’t see check points added to
my tests while using Selenium IDEL, how do I get them
added to my tests?
You need to use context menu to add check
points to your Selenium IDE tests
Q.36.How do I edit tests in Selenium
IDE?
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
Q.37.What is syntax
of command used in Selenium?
There
are three entities associated with a command –
· Name of Command
· Element Locator (also known as Target)
·
Value (required when using echo, wait etc)
Q.38.There are tons
of Selenium Command, am I going to use all of them
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/assertElementPresent:
verifies/asserts presence of element, in the page. ·verify/assertTextPresent
verifies/asserts expected text is somewhere on the page.
Q.39. How do I use
html id and name while using Selenium IDE
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
Q.40.What is XPath?
When would I have to use XPath in Selenium IDE?
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')]
Q.41.What is CSS
location strategy in Selenium?
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’)
Q.42.There is id,
name, XPath, CSS locator, which one should I use?
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.
Q.43. I want to
generate random numbers, dates as my test data, how do I do this in Selenium
IDE?
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()}
Q.44.Can I store
result of an evaluation and use it later in my test?
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}
Q.45.I have stored
result of an evaluation; can I print it in IDE to check its value?
You can use echo command as following to
check the stored value in Selenium IDE –
storeText
css=input#s
var1
echo
${var1}
Q.46.Can I handle java
script alert using Selenium?
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.
Q.47.Selenium has
recorded my test using XPath, how do I change them to css locator?
You can use drop down available next to Find in Selenium to change
element locator used by Selenium
Q.48.I have written
my own element locator, how do I test it?
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.
Q.49.I have written
one js extension; can I plug it in Selenium and use it?
You could specify you js extension in
“Options” window of Selenium IDE –
Q.50. How do I
convert my Selenium IDE tests from Selenese to another language?
You could use Format option of
Selenium IDE to convert tests in another programming language
Q.51.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
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.
Q.52.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?
You can execute you Selenese test in another browser by specifying the
“-html Suite” followed by path of your Selenese suite while starting the
Selenium Server. Selenium Server would be covered in details in question
about Selenium RC.
Q.53.I have added one
command in middle of list of commands, how do I test only this new command?
You can double click on newly added command and Selenium IDE would
execute only that command in browser.
Q.54.Can I make Selenium IDE tests
begin test execution from a certain command and not from the very first
command?
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 option.
Q.55.Are there other
tools available outside Selenium IDE to help me tests my element locators
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.
Q.56.What is upcoming
advancement in Selenium IDE?
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
Q.57.How can I use
looping option (flow control) is Selenium IDE
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.
Q.58.Can I use screen
coordinate while using click command? I want to click at specific part of my element.
You would need to use clickAT command to
achieve. clickAt command accepts element locator and x, y coordinates as
arguments –
clickAt(locator,
coordString)
Q.59.How do I verify
presence of drop down options using Selenium?
Use
assertSelectOptions as following to check options in a drop down list –
assertSelectOptions
Q.60.Can I get data
from a specific html table cell using Selenium IDE?
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
Q.61.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?
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.
Q.62.My application
has dynamic alerts which don’t always appear, how do I handle them?
If
you want to simulate clicking “ok “ on alert than use – chooseOkOnNextConfirmation
and if you want to simulate clicking “cancel” on alert than use http://draft.blogger.com/blogger.g?blogID=4608630209994205502chooseCancelOnNextConfir
mation
( )
Q.63.Can I right
click on a locator?
You can use command - contextMenu(
locator) to simulate right click on an element in web page.
Q.64.How do I capture
screen shot of page using Selenium IDE?
Use
command – captureEntirePageScreenshot to take screen shot of page.
Q.65.I want to pause
my test execution after certain command.
Use pause command which takes time in
milliseconds and would pause test execution for specified time – pause (
waitTime )
Q.66.I used open
command to launch my page, but I encountered time out errorL
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
“http://draft.blogger.com/blogger.g?blogID=4608630209994205502setTimeout
( timeout )” to make selenium IDE wait for specified time, before proceeding
with test execution.
Q.67.What’s the
difference between type and typeKeys commands?
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. Selenium
RC (Selenium 1.0) Questions
Q.68.What is Selenium
RC (also known as Selenium 1.0)?
Selenium RC is an offering from SeleniumHQ which tries to overcome
following draw backs of Selenium IDE –
· Able to execute tests only with
Firefox
· Not able to use full-fledged
programming language and being limited to Selenese
Q.69.What are the
main components of Selenium RC?
Selenium
RC has two primary components –
· Client libraries which let you writes
tests in language of your preference i.e. java, C#, perl, php etc
· Selenium sever which acts as a proxy
between browser and application under test (aut)
Q.70.Why do I need Selenium Server?
Selenium uses java script to drives tests on a browser; Selenium injects
its own js to the response which is returned from aut. But there is a java
script security restriction (same origin policy) which lets you modify html of
page using js only if js also originates from the same domain as html. This
security restriction is of utmost important but spoils the working of Selenium.
This is where Selenium server comes to play an important role. Selenium server
stands between aut and browser and injects selenium js to the response received
format and then it is delivered to browser. Hence browser believes that entire
response was delivered from aut.
Q.71.What is Selenium
core? I have never used it!!!
Selenium core is the core js engine of Selenium which executes tests on
browser, but because of same origin policy it needs to be deployed on app
server itself, which is not always feasible. Hence Selenium core is not used in
isolation. Selenium IDE as well as Selenium RC use Selenium core to drive tests
while over coming same origin policy. In case of Selenium IDE tests are run in
context of browser hence it is not hindered by same origin policy and with
Selenium RC, Selenium Server over comes same origin policy.
Q.72.Where is
executable for Selenium RC, how do I install it?
Installation is a misnomer for Selenium RC. You don’t install Selenium
RC you only add client libraries to you project. For example in case of java
you add client driver and Selenium server jars in Eclipse or IntelliJ which are
java editors.
Q.73.I have
downloaded Selenium Server and Client libraries, how do I start Selenium
Server?
To start Selenium Server, you need to
navigate to installation directory of Selenium server and execute following
command –
Java
-jar .jar
This
will start Selenium server at port 4444 by default.
Notice that you need to have java
version 1.5 or higher available on your system to be able to use
Selenium
server.
Q.74.On my machine
port 4444 is not freeL . How do Use another port?
You can specify port while running the
selenium server as –
Java
-jar .jar –port 5555
Q.75.I am new to
programming; can Selenium generate sample code from my Selenese scripts?
You can first record tests in Selenium IDE and then use format option to
convert them in a language of your choice.
Q.76.Can I start
Selenium server from my program instead of command line
If you are using java then you can start Selenium server using
SeleniumServer class. For this you need to instantiate SeleniumServer and then
call start() method on it.
seleniumServer = new SeleniumServer();
seleniumServer.start();
Q.77. How do I start
the browser?
While using java you need to create instance of DefaultSelenium class
and pass it four parameters – selenium = new DefaultSelenium(serverHost,
serverPort, browser,
appURL);
selenium.start();
Herein
you need to pass,
host
where Selenium server is running,
port
of Selenium server,
browser
where tests are to be executed and
application
URL
Q.78.I am not using
java to program my tests, do I still have to install java on my system?
Yes, since Selenium server is written in java you need java to be installed
on your system to be able to use it. Even though you might not be using java to
program your tests.
Q.79.What are the browsers offering
from Selenium?
Following browsers could be used with
Selenium – *firefox
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom
Here
pi and proxy stand for proxy injection mode of Selenium server
Q.80.During execution
of tests I see two browser windows; one my test application another window shows
commands being executed. Can I limit it to just one window?
Yes you can instruct Selenium Server to launch just one window. To do so
you must specify – singleWindow while starting the Selenium server as –
Java -jar .jar –singleWindow
Q.81.My tests usually
time outL. Can I specify bigger time out?
This usually happens while using open method with Selenium. One way to
overcome this is to usesetTimeOut method in your test script another way is to
specify time out while starting
Selenium server as following –
Java -jar .jar –timeout
Q.82.My system is
behind corporate network, how do I specify my corporate proxy?
You can specify your corporate proxy as
following while starting Selenium Server – java -jar .jar -Dhttp.proxyHost=
-Dhttp.proxyPort= -Dhttp.proxyUser= -Dhttp.proxyPassword=
Q.83.I am switching
domains in my test scripts. I move from “yahoo.com” to “google.com” and my tests
encounter permission denied errorL
Changing domains is also a security restriction from java script. To
overcome this you should start you Selenium server in proxy injection mode as –
java -jar .jar –proxyInjectionMode
Now Selenium server would act as proxy
server for all the content going to test application
Q.84.Can I execute my
Selenese tests in another browser using Selenium server? I want to use only Selenese
script my tests but still want to execute my test in non firefox browsers
Yes you can. To do so you need to specify
following parameters while starting Selenium server – Browser
Test
domain
Path
to html suite (you Selenese tests) and
Path
to result
java
-jar <>.jar -htmlSuite
Q.85.Can I log more
options during test execution?
If you want to log browser side option
during test execution then you should start Selenium server as following –
java
-jar <>.jar –browserSideLog
Q.86.Can I use
Selenium RC on my UNIX/Mac also?
You can use Selenium RC on any system which is capable I running Java.
Hence you can use it on RC and UNIX machines also
Q.87.I want to test my scripts on new
experimental browser, how do I do that?
You can specify *custom followed by path to browser to execute your
tests on any browser while starting Selenium server *custom
Q.88.I executed my
tests cases but where is the test report?
Selenium RC itself does not provide any mechanism for test reporting.
Test reporting is driven from the framework you use for Selenium. For example
with java client driver of Selenium –
·if you are using
JUnit then you can use ant plug-in of JUnit to generate test report · if you are using
TestNG then TestNG generates reports for you
Same reporting option is available with
PHP unit and other client libraries you are using.
Q.89.How do I use
recovery scenarios with Selenium? I used to use them with QTP.
Power of recovery scenarios lies with the programming language you use.
If you are using java then you can use Exception handling to overcome same. For
example if you are reading data from a file and file is not available then you
should keep you code statements in “try catch” block so that test execution
could continue even in the wake of errors. Such mechanism entirely boils down
the errors you want to recover from, while being able to continue with test
execution.
Q.90.How do I iterate
through options in my test script.
You can use loop features of the programming language, for example you
can use “for” loop in java as following to type different test data in a text
box –
//
test data collection in an array
String[]
testData = {"test1", "test2", "test3"};
//
iterate through each test data
for
(String s : testData) {
selenium.type(“elementLocator”,
testData);
Q.91.Can I execute java script from my
tests? I want to count number of images on my page.
You can use method getEval() to evaluate java script. For example if you
want to count number of images then you can pass following dom statement to
getEval() as following –
selenium.getEval("window.document.images.length;");
Or
to get All anchor objects from a page
selenium.getEval("window.document.getElementsByTagName(‘a’);");
Q.92.Is there a way
for me to know all available options when I start Selenium Server?
If you want to see all options available while starting Selenium server
then you should use option “-h” while starting Selenium server - Java –jar .jar
–h
It would display you all the options
which you can use while starting the Selenium server.
Q.93.I have created
my own firefox profile; can I execute my test scripts on it
You may like to create your own firefox profile because Selenium always
created a clean firefox profile while executing the tests and none of your FF
settings and plug-in are considered with this clean profile. If you want to
execute tests on FF with your settings then you should create custom profile
for FF. To be able to execute tests on a custom firefox profile you should specify
its path while starting Selenium server. For example if your new profile is
stored at “awesome location” in your directory then you should start Selenium
server as following – Java –jar .jar -firefoxProfileTemplate "awesome location"
Q.94.How do I capture
server side log from Selenium server?
Start your Selenium Server as following –
java
-jar .jar -log selenium.log
And
Selenium would start logging server side info, i.e.
20:44:25
DEBUG [12] org.openqa.selenium.server.SeleniumDriverResourceHandler - Browser
12345/:top frame1 posted START NEW
Q.95.What are Heightened Privileges
Browsers?
Firefox and IE have browser modes which
are not restricted by java script’s same origin policy. These browsers are
known as browsers with elevated security privileges. In case of Firefox it is known
as chrome (It’s not the Google browser) and in case of IE it is known as iehta
Q.96.My application
has lots of pop up window, how do I work with them?
You need to know the Window ID of pop window to be able to work with
them. First you need to bring control on pop up window; execute selenium
commands there, close the pop up window and then bring control back to main
window. Consider following example where click on an image brings a pop up
window –
//
click on image brings pop up window
selenium.click("css=img");
//
wait for pop up window identified using anchor target "ss"
selenium.waitForPopUp("ss",
getWaitPeriod());
selenium.selectWindow("ss");
//
Some more operations on popup window
//
Close the pop up window and Select the main application
window
//
Main window is selected by adding null as argument
selenium.close();
selenium.selectWindow("null");
//
continue with usual operation J
Question
80:
While
trying to execute my tests with firefox I encountered following error –
“Firefox Refused
Shutdown
While Preparing a Profile”. How do I solve it?
Answer
This
message simply means that Selenium is not able to launch FF browser as it is
already
Running
on your system. To overcome this you should close all running instances of FF
browser.
You
should also check your system process if there is any hidden FF profile running
which is not
Visible
on screen. You should kill all FF processes and following this your tests
should run smooth
Q.97.While trying to
execute my tests with Firefox I encountered following error – “Firefox Refused
Shutdown While
Preparing a Profile”. How do I solve it?
This message simply means that Selenium is not able to launch FF browser
as it is already running on your system. To overcome this you should close all
running instances of FF browser. You should also check your system process if
there is any hidden FF profile running which is not visible on screen. You
should kill all FF processes and following this your tests should run smooth
Q.98.My application
uses Ajax heavily how do I use Selenium RC to work with Ajax operations?
Ajax operations don’t reload a page like
normal form submission but they make http requests behind the scene. You cannot
use waitForPageToLoad for such operations and instead should use conditional
wait for change in state of application. This could as well mean waiting for presence
of an element before continuing with test operations. Consider following
example in which type operation triggers Ajax operation which is followed by
conditional wait for presence of a text box – // type operation brings element
“q” on screen without loading the page
selenium.type("elementLocator",
"testData");
//
conditional wait for element “q”
for
(int second = 0;; second++) {
if
(second >= 60) fail("timeout");
try
{ if (selenium.isElementPresent("q")) break;
}
catch (Exception e) {}
Thread.sleep(1000);
}
Q.99.How do I upload
a file using Selenium? I need to upload a word file during test execution.
If you are using Firefox then you can use “type” command to type in a
File Input box of upload file. But type operation does not work with IE and you
would have to use “Robot” class in java to work make file upload work.
Q.100.Why do I get
“permission denied” error during execution of Selenium tests?
The primary reason of permission denied error is same origin policy
restriction from java script. To overcome this error you can use browsers with
elevated security privileges. In case of Firefox you should use *chrome and in
case of IE you should use *iehta as browser for working with Selenium.