Selenium Web Driver
Selenium Web Driver
WebDriver and RC: It provide the APIs for a variety of languages like
Java, .NET, PHP, etc. With most of the browsers Webdriver and RC works.
Grid: With the help of Grid you can distribute tests on multiple machines
so that test can be run parallel which helps in cutting down the time
required for running in browser test suites
Web Testing tools Selenium RC and WebDriver are consolidated in single tool in
Selenium 2.0
3) Mention what is Selenium 3.0?
Selenium 3.0 is the latest version of Selenium. It has released 2 beta versions of
selenium 3.0 with few of the below changes:
It will support for Firefox Via Grid fixes NPE’s on registration when -browse
Mozilla’s geckodriver not specified
ID
Name
Tag
Attribute
CSS
Linktext
PartialLink Text
Xpath etc
b) Regression
For post release validation with continuous integration automation tool could be
used
a) Jenkins
b) Hudson
c) Quick Build
d) CruiseCont
Assertion is used as a verification point. It verifies that the state of the application
conforms to what is expected. The types of assertion are “assert” , “verify” and
“waifFor”.
8) Explain the difference between single and double slash in X-path? Single
slash ‘/ ’
9) List out the technical challenges with Selenium? Technical challenges with
Selenium are
For any reporting related capabilities have to depend on third party tools
10) What is the difference between type keys and type commands ?
TypeKeys() will trigger JavaScript event in most of the cases whereas .type()
won’t. Type key populates the value attribute using JavaScript whereas
.typekeys() emulates like actual user typing
Assert: Assert allows to check whether an element is on the page or not. The
test will stop on the step failed, if the asserted element is not available. In other
words, the test will terminated at the point where check fails.
Verify: Verify command will check whether the element is on the page, if it is not
then the test will carry on executing. In verification, all the commands are going
to run guaranteed even if any of test fails.
12) What is JUnit Annotations and what are different types of annotations
which are useful ?
In JAVA a special form of syntactic meta-data can be added to Java source code,
this is know as Annotations. Variables, parameters, packages, methods and
classes are annotated some of theJunit annotations which can be useful are
Test
Before
After
Ignore
BeforeClass
AfterClass
RunWith
13) While using click command can you use screen coordinate?
To click on specific part of element, you would need to use clickAT command.
ClickAt command accepts element locator and x, y co-ordinates as arguments-
clickAt (locator, cordString)
15) Why testers should opt for Selenium and not QTP? Selenium is more
popular than QTP as
Selenium is used specially for testing web based applications while QTP can be
used for testing client server application also
16) What are the four parameter you have to pass in Selenium? Four
parameters that you have to pass in Selenium are
Host
Port Number
Browser
URL
17) What is the difference between setSpeed() and sleep() methods?
Thread.sleep () : It will stop the current (java) thread for the specified period of
time. Its done only once
SetSpeed () : For specific amount of time it will stop the execution for every
selenium command.
This command is useful for demonstration purpose or if you are using a slow
web application
18) What is same origin policy? How you can avoid same origin policy?
The “Same Origin Policy” is introduced for security reason, and it ensures that
content of your site will never be accessible by a script from another site. As per
the policy, any code loaded within the browser can only operate within that
website’s domain.
To avoid “Same Origin Policy” proxy injection method is used, in proxy injection
mode the Selenium Server acts as a client configured HTTP proxy , which sits
between the browser and application under test and then masks the AUT under a
fictional URL
element.submit () ;
Alternatively you can use click method on the element which does form
submission
21) What are the features of TestNG and list some of the functionality in
TestNG which makes it more effective?
22) Mention what is the difference between Implicit wait and Explicit wait?
Implicit Wait: Sets a timeout for all successive Web Element searches. For the
specified amount of time it will try looking for element again and again before
throwing a NoSuchElementException. It waits for elements to show up.
23) Which attribute you should consider throughout the script in frame for
“if no frame Id as well as no frame name”?
You will ned to switch to each and every frame and search for locator which we
want.
24) Explain what is the difference between find elements () and find element
() ?
findElements () : Using the given “locating mechanism” find all the elements
within the current page. It returns a list of web elements.
25) Explain what are the JUnits annotation linked with Selenium?
@Before public void method() – It will perform the method () before each
test, this method can prepare the test
@Test public void method() – Annotations @Test identifies that this method
is a test method environment
Datadriven framework: In this framework, the test data is separated and kept
outside the Test Scripts, while Test Case logic resides in Test Scripts. Test data is
read from the external files ( Excel Files) and are loaded into the variables inside
the Test Script. Variables are used for both for input values and for verification
values.
27) Explain how you can login into any site if it’s showing any
authentication popup for password and username?
Syntax-http://username:password@url
ex- http://creyate:[email protected]
WebElement el = driver.findElement(By.id(“ElementID”))
29) Explain what is the difference between Borland Silk and Selenium?
Borland Silk test is not a free Selenium is completely free test automation too
testing tool
Silk test supports only Internet Selenium supports many browsers like Internet
Explorer and Firefox Explorer, Firefox, Safari, Opera and so on
Silk test uses test scripting Selenium suite has the flexibility to use many
language languages like Java, Ruby,Perl and so on
Silk test can be used for client Selenium can be used for only web application
server applications
Selenium Grid sent the tests to the hub. These tests are redirected to Selenium
Webdriver, which launch the browser and run the test. With entire test suite, it
allows for running tests in parallel.
Selenium Web driver makes direct calls to browser using each browsers
native support for automation, while Selenium RC requires selenium server
to inject Javascript into the browser
Handling multiple frames, pop ups , multiple browser windows and alerts
Multi browser testing including improved functionality for browser not well
supported by Selenium 1.0
36) Explain how you can find broken images in a page using Selenium Web
driver ?
Get XPath and get all the links in the page using tag name
You can use following command to store a value which is text box using web
driver
WebDriverException
NoAlertPresentException
NoSuchWindowException
NoSuchElementException
TimeoutException
41) Explain using Webdriver how you can perform double click ?
act.doubleClick(webelement);
You can use “type”command to type in a file input box of upload file. Then, you
have to use “Robot” class in JAVA to make file upload work.
44) Explain how you can handle frames using Selenium 2.0 ?
To bring control on HTML frame you can use “SwitchTo” frame method-
driver.switchTo().frame(“frameName”);
driver.switchTo().frame(“parentFrame.4.frameName”);
This would bring control on frame named- “frameName” of the 4 th sub frame
names “parentFrame”
getwindowhandles(): It is used to get the address of all the open browser and its
return type is Set<String>
getwindowhandle(): It is used to get the address of the current browser where the
control is and return type is string
Syntax-driver.switchTo().defaultContent();
By.id()
By.name()
By.tagName()
By.className()
By.linkText()
By.partialLinkText()
By.xpath
By.cssSelector()
48) What is the command that is used in order to display the values of a
variable into the output console or log?
If order to display the value of a variable you can use command like echo $
{variable name>>
Above is using PHP. If you are using Java, replace echo with System.out.println
49) Explain how you can use recovery scenario with Selenium?
Recovery scenarios depends upon the programming language you use. If you
are using Java then you can use exception handling to overcome same. By
using “Try Catch Block” within your Selenium WebDriver Java tests
To iterate through options in test script you can loop features of the programming
language, for example to type different test data in a text box you can use “for”
loop in Java
51) How can you prepare customized html report using TestNG in hybrid
framework ?
TestNG: Using inbuilt default.html to get the HTML report. Also XST reports
from ANT, Selenium,Testng combinations
Using our own customized reports using XSL jar for converting XML
content to HTML
52) From your test script how you can create html test report?
TestNG: Using inbuilt default.html to get the HTML report. Also XLST
reports from ANT, Selenium, TestNG combination
Using our own customized reports using XSL jar for converting XML
content to HTML
53) Explain how you can insert a break point in Selenium IDE ?
Select “Toggle break point” by right click on the command in Selenium IDE
Press “B” on the keyboard and select the command in Selenium IDE
54) Explain in Selenium IDE how can you debug the tests?
Insert a break point from the location from where you want to execute test
step by step
Click on the “Run” button to continue executing all the commands at a time
Selenese is a selenium set of command which are used for running the test
Actions: It is used for performing the operations and interactions with the
target elements
Reading from the external files like .txt, .xls is not possible
58) In selenium IDE what are the element locators that can be used to
locate elements on web page?
X-path locators
Css locators
Html id
Html name
59) In Selenium IDE how you can generate random numbers and dates for
test data ?
In Selenium IDE you can generate random numbers by using Java Script
type
css=input#s
javascript{Math.random()}
And for
type
css=input#s
javascript{new Date()}
60) How you can convert any Selenium IDE tests from Selenese to another
language?
You can use the format option of Selenium IDE to convert tests into another
programming language
61) Using Selenium IDE is it possible to get data from a particular html
table cell ?
storeTable
Css=#table 0.2
textFromCell
When a locator has changed and Selenium IDE cannot locate the element
When element Selenium IDE waiting to access did not appear on the web
page and the operation timed out
When element Selenium IDE was trying to access was not created
63) Explain how you can debug the tests in Selenium IDE ?
Insert a break point from the location where you want to execute step by
step
64) From Selenium IDE how you can execute a single line?
From Selenium IDE single line command can be executed in two ways
Select “Execute this command” by right clicking on the command in
Selenium IDE
Press “X” key on the keyboard after selecting the command in Selenium
IDE
65) In which format does source view shows your script in Selenium IDE ?
66) Explain how you can insert a start point in Selenium IDE?
Press “S” key on the keyboard and select the command in Selenium IDE
In Seleniun IDE right click on the command and the select “Set / Clear
Start Point”
67) What if you have written your own element locator and how would you
test it?
To test the locator one can use “Find Button” of Selenium IDE, as you click on it,
you would see on screen an element being highlighted provided your element
locator is right or or else an error message will be displayed
68) What is regular expressions? How you can use regular expressions in
Selenium ?
A regular expression is a special text string used for describing a search pattern.
In Selenium IDE regular expression can be used with the keyword- regexp: as a
prefix to the value and patterns needs to be included for the expected values.
70) How will you handle working with multiple windows in Selenium ?
71) How will you verify the specific position of an web element
You can use verifyElementPositionLeft & verifyElementPositionTop. It does a
pixel comparison of the position of the element from the Left and Top of page
respectively
You can use the storeAlert command which will fetch the message of the alert
pop up and store it in a variable.
Selenium IDE have limitations in terms of browser support and language support.
By using Selenium RC limitation can be diminished.
Selenium RC is a java based and using any language it can interact with
the web application
Using server you can bypass the restriction and run your automation script
running against any web application
Selenium IDE does not directly support many functions like condition statements,
Iteration, logging and reporting of test results, unexpected error handling and so
on as IDE supports only HTML language. To handle such issues Selenium RC is
used it supports the language like Perl, Ruby, Python, PHP using these
languages we can write the program to achieve the IDE issues.
Advantages of RC are
Loops and conditions can be used for better performance and flexibility
Support many Programming languages and Operating Systems
77) Explain what is framework and what are the frameworks available in
RC?
A collection of libraries and classes is known as Framework and they are helpful
when testers has to automate test cases. NUnit, JUnit, TestNG, Bromine, RSpec,
unittest are some of the frameworks available in RC .
79) What are the technical limitations while using Selenium RC?
Apart from “same origin policy” restriction from js, Selenium is also restricted from
exercising anything that is outside browser.
Yes, it is possible when you are not using JAVA testing framework. Instead of
using Java testing framework if you are using java client driver of selenium then
TestNG allows you to do this. By using “parallel=test” attribute you can set tests
to be executed in parallel and can define two different tests, each using different
browser.
If you want full automation against different server and client platforms, You need
a way to invoke the tests from a command line process, reports that tells you
what happened and flexibility in how you create your test suites. TestNG gives
that flexibility.
82) Explain how you can capture server side log Selenium Server?
To capture server side log in Selenium Server, you can use command
83) Other than the default port 4444 how you can run Selenium Server?
You can run Selenium server on java-jar selenium-server.jar-port other than its
default port
84) How Selenium grid hub keeps in touch with RC slave machine?
At predefined time selenium grid hub keeps polling all RC slaves to make sure it
is available for testing. The deciding parameter is called
“remoteControlPollingIntervalSeconds” and is defined in
“grid_configuration.yml”file
86) To enter values onto text boxes what is the command that can be used?
isElementPresent(String locator)
Few points that favor Python over Java to use with Selenium is,
Java uses traditional braces to start and ends blocks, while Python uses
indentation.
Using "pause" command for handling Ajax call is not completely reliable.
Long pause time makes the test unacceptably slow and increases the
testing time. Instead, "waitforcondition" will be more helpful in testing Ajax
applications.
Creating automated test request may be difficult for testing tools as such
AJAX application often use different encoding or serialization technique to
submit POST data.
Intellij is an IDE that helps you to write better and faster code for Selenium. Intellij
can be used in the option to Java bean and Eclipse.
IAnnotationTransformer
IAnnotationTransformer2
IConfigurable
IConfigurationListener
IExecutionListener
IHookable
IInvokedMethodListener
IInvokedMethodListener2
IMethodInterceptor
IReporter
ISuiteListener
ITestListener
The desired capability is a series of key/value pairs that stores the browser
properties like browser name, browser version, the path of the browser driver in
the system, etc. to determine the behavior of the browser at run time.
For Selenium,
When you want to run the test cases on a different browser with different
operating systems and versions.
For Database Testing in Selenium Webdriver, you need JDBC (Java Database
Connectivity) API. It allows you to execute SQL statements.
While working with Selenium, you need Session Handling. This is because,
during test execution, the Selenium WebDriver has to interact with the browser all
the time to execute given commands. At the time of execution, it is also possible
that, before current execution completes, someone else starts execution of
another script, in the same machine and in the same type of browser. So to avoid
such situation you need Session Handling.
100) Mention what are the advantages of Using Git Hub For Selenium?
Multiple people when they work on the same project they can update
project details and inform other team members simultaneously.
Jenkins can help you to build the project from the remote repository
regularly. This helps you to keep track of failed builds.