Selenium Flashcards
What is Selenium?
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. It is quite similar to HP Quick Test Pro (QTP now UFT) only that Selenium focuses on automating web-based applications.
What are the advantages of using Selenium over QTP?
QTP and Selenium are the most used tools in the market for software automation testing. Hence it makes sense to compare the pros of Selenium over QTP.
What are the disadvantages of using Selenium over QTP?
Here are some disadvantages when comparing these two technologies
What is WebDriver?
WebDriver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox, Chrome (unlike Selenium IDE).
WebDriver also enables you to use a programming language in creating your test scripts (not possible in Selenium IDE).
You can now use conditional operations like if-then-else or switch-case. You can also perform looping like do-while.
What is the syntax for instantiating a new driver class?
The syntax is dependent on which browser the user plans to use. The syntax for FireFox, Google Chrome, and Internet Explorer in order are:
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();
What are locators?
Locators provide a way to access the HTML elements from a web page to perform operations on it. Types of locators include:
- Id
- Name
- Classname
- Link text
- CSS selector
- Xpath
What would be an example of an unreliable id?
If an id includes alpha numeric characters, then it is not reliable
What is an example of an unreliable classname?
Class names should not include spaces
From what direction does Selenium scan the DOM?
Selenium scans from top left to bottom right
What is an example of an unreliable xpath?
If an xpath starts with html, it is not reliable
What is the syntax for verifying xpaths and CSS locators in the DOM console?
$(“”) for CSS
$x(“”) for xpath
What is the syntax for an xpath?
//tagname[@attribute=’value’]
What are the syntaxes for CSS locators?
tagName[attribute=’value’]
tagName#id
tagname.classname
What is the syntax for an xpath regular expression?
//tagName[contains(@attribute,’value’)]
What is the syntax for a CSS regular expression?
tagName[Atrribute*=’value’]
What is the difference between a relative xpath and an absolute xpath?
An absolute xpath starts with the root node
A relative xpath is one where the path starts from the node of your choice
What are xpath axes?
XPath axes comes in handy when the exact element tagname or its attribute value are dynamic and cannot be used to locate an element. In this case locating element after traversing through child/sibling or parent will be the standard approach
What is the syntax for “Following” xpath axes?
This XPath axes helps to locate element following the current node
Xpath=//input[@name=’ organization_name’]//following::input[1]
Xpath= //input[@name=’ organization_name’]//following::input
In the above-mentioned examples, the first one will select the input following the organization element, whereas in the second example, it will select all elements following the organization element having input tag.

What is the syntax for “Following sibling” axes?
In case of following siblings, all following nodes of the context node, that shares the same parent, are applicable. In this case all siblings are referred to as children of the parent node. So if you are referencing one of the children and wish to navigate to other children of the same parent that follows it, following sibling does the job
Xpath= //li[@class=’sign-in’]//following-sibling::li
What is the syntax for the “preceding” axes?
This method helps in locating element before the current node, as in the preceding element from the current node with XPath in Selenium
In the example below, the first one will locate element with the field as email whereas the other one will locate all elements before the current node i.e. password field.
Xpath=//input[@name=’password’]//preceding::input[1]
Xpath=//input[@name=’password’]//preceding::input

What are some important Get Commands?
Get commands fetch various important information about the page/element. Here are some important “get” commands you must be familiar with.
What are some important navigate commands?
These commands allow you to refresh,go-into and switch back and forth between different web pages
What are some commands for closing browser windows?
What is an implicit wait?
The implicit wait will tell to the web driver to wait for certain amount of time before it throws a “No Such Element Exception”. The default setting is 0. Once we set the time, web driver will wait for that time before throwing an exception.
In the below example we have declared an implicit wait with the time frame of 10 seconds. It means that if the element is not located on the web page within that time frame, it will throw an exception.
driver.manage().timeouts().implicitlyWait(TimeOut, TimeUnit.SECONDS);