101) Compare HP QTP vs Selenium?

When QA team considers acquiring test automation to assist in testing, one of the most critical decisions is what technologies or tools to use to automate the testing. The most obvious approach will be to look to the software market and evaluate a few test automation tools. Read Selenium vs QTP comparison

102) Compare Borland Silktest vs Selenium?
Check Selenium vs SilkTest comparison

103) How to test Ajax application with Selenium?
Ajax interview questions could be tough for newbie in the test automation, but will be easily cracked by Selenium Tester with a relevant experience. Read the detailed approach at Testing Ajax applications with Selenium in the right way

104) How can I learn to automate testing using Selenium?
Don't be surprised if the interviewer asks you to describe the approach for learning Selenium. This interviewer wants to hear how you can innovative software test automation process the company. Most likely they are looking for software professional with a good Selenium experience, who can do Selenium training for team members and get the team started with test automation. I hope this Selenium tutorial will be helpful in the preparation for this Selenium interview question.

105) . What are the main components of Selenium testing tools?
Selenium IDE, Selenium RC and Selenium Grid

106) 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.

107) Explain what is the difference between Borland Silk and Selenium?

Silk Test Tool

Selenium Test Tool

  • Borland Silk test is not a free testing tool
  • Selenium is completely free test automation tool
  • Silk test supports only Internet Explorer and Firefox
  • Selenium supports many browsers like Internet Explorer, Firefox, Safari, Opera and so on
  • Silk test uses test scripting language
  • Selenium suite has the flexibility to use many languages like Java, Ruby,Perl and so on
  • Silk test can be used for client server applications

108) Explain how Selenium Grid works?

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.

109) Can we use Selenium grid for performance testing?

Yes. But not as effectively as a dedicated performance testing tool like Loadrunner.

110 ) List the advantages of Webdriver over Selenium Server?

  • If you are using Selenium-WebDriver, you don’t need the Selenium Server as it is using totally different technology
  • Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility
  • 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

111) Mention what are the capabilities of Selenium WebDriver or Selenium 2.0 ?

WebDriver should be used when requiring improvement support for

  • Handling multiple frames, pop ups , multiple browser windows and alerts
  • Page navigation and drag & drop
  • Ajax based UI elements
  • Multi browser testing including improved functionality for browser not well supported by Selenium 1.0

112) Explain how you can find broken images in a page using Selenium Web driver ?

To find the broken images in a page using Selenium web driver is

  • Get Xpath and get all the links in the page using tag name
  • In the page click on each and every link
  • Look for 404/500 in the target page title

113) Mention 5 different exceptions you had in Selenium web driver?

The 5 different exceptions you had in Selenium web drivers are

  • WebDriverException
  • NoAlertPresentException
  • NoSuchWindowException
  • NoSuchElementException
  • TimeoutException

114) How will you use Selenium to upload a file ?

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.

115) Why should Selenium be selected as a test tool?

Selenium

  • is free and open source
  • have a large user base and helping communities
  • have cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.)
  • have great platform compatibility (Windows, Mac OS, Linux etc.)
  • supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
  • has fresh and regular repository developments
  • supports distributed testing

116 ) What are the testing types that can be supported by Selenium?

Selenium supports the following types of testing:

  • Functional Testing
  • Regression Testing

117) What are the limitations of Selenium?

Following are the limitations of Selenium:

  • Selenium supports testing of only web based applications
  • Mobile applications cannot be tested using Selenium
  • Captcha and Bar code readers cannot be tested using Selenium
  • Reports can only be generated using third party tools like TestNG or Junit.
  • As Selenium is a free tool, thus there is no ready vendor support though the user can find numerous helping communities.
  • User is expected to possess prior programming language knowledge.

118) What is Selenese?

Selenese is the language which is used to write test scripts in Selenium IDE.

119) What are the different types of locators in Selenium?

Locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:

  • ID
  • ClassName
  • Name
  • TagName
  • LinkText
  • PartialLinkText
  • Xpath
  • CSS Selector
  • DOM

120) Which is the latest Selenium tool?

WebDriver

121) How to type in a textbox using Selenium?

User can use sendKeys(“String to be entered”) to enter the string in the textbox.

122) What is difference between assert and verify commands?

Assert: Assert command checks whether the given condition is true or false. Let’s say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed.

Verify: Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halts i.e. any failure during verification would not stop the execution and all the test steps would be executed.

Q 123) What is an Xpath?

Xpath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being markup languages and since they fall under the same umbrella, Xpath can be used to locate HTML elements.

The fundamental behind locating elements using Xpath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.

Q 124) What is the difference between “/” and “//” in Xpath?

Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.

Double Slash “//” – Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.

Q 125) What is Same origin policy and how it can be handled?

The problem of same origin policy disallows to access the DOM of a document from an origin that is different from the origin we are trying to access the document.

Origin is a sequential combination of scheme, host and port of the URL. For example, for a URL http:// http://www.softwaretestinghelp.com/resources/, the origin is a combination of http, softwaretestinghelp.com, 80 correspondingly.

Thus the Selenium Core (JavaScript Program) cannot access the elements from an origin that is different from where it was launched. For Example, if I have launched the JavaScript Program from “http://www.softwaretestinghelp.com”, then I would be able to access the pages within the same domain such as “http://www.softwaretestinghelp.com/resources” or “http://www.softwaretestinghelp.com/istqb-free-updates/”. The other domains like google.com, seleniumhq.org would no more be accessible.

So, In order to handle same origin policy, Selenium Remote Control was introduced.

Q126) When should I use Selenium Grid?

Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.

127) What must one set within SIDE in order to run a test from the beginning to a certain point within the test?
Set Toggle BreakPoint.

128) . What does a right-pointing green triangle at the beginning of a command in SIDE indicate?
Play Entire Test Suite

129) Which wildcards does SIDE support?
*, [ ]

130) What are the four types of regular expression quantifiers which we've studied?
Ans : * quantifier: 0 or more of the preceding character (or group)
+ quantifier: 1 or more of the preceding character (or group)
? quantifier: 0 or 1 of the preceding character (or group)
{1,5} quantifier: 1 through 5 of the preceding character (or group)

131) . What regular expression special character(s) means "any character?"
(.*)

132) . What distinguishes between an absolute and relative URL in SIDE?
Absolute URL: Its is base url and this represent domain address.
Relative URL: (Absolute URL + Page Path).
Open command uses Base URL (Absolute URL) to navigate web page.

133) . How would one access a Selenium variable named "count" from within a JavaScript snippet?
${count}

134) What Selenese command can be used to display the value of a variable in the log file, which can be very valuable for debugging?
echo()

135) 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”);

To specify a frame you can use index number

driver.switchTo().frame(“parentFrame.4.frameName”);

This would bring control on frame named- “frameName” of the 4th sub frame names “parentFrame”

136) 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

137) Explain how you can insert a break point in Selenium IDE ?

In Selenium IDE to insert a break point

  • 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
  • Multiple break points can be set in Selenium IDE

138) Explain what are the limitations of Selenium IDE?

The limitations of Selenium IDE

  • Exceptional handling is not present
  • Selenium IDE uses only HTML languages
  • External databases reading is not possible with IDE
  • Reading from the external files like .txt, .xls is not possible
  • Conditional or branching statements execution like if,else, select statements is not possible

139) What are the two modes of views in Selenium IDE ?

Either Selenium IDE can be opened as a pop up window or in side bar

140) In selenium IDE what are the element locators that can be used to locate elements on web page?

In selenium there are mainly 4 locators that are used

  • X-path locators
  • Css locators
  • Html id
  • Html name

141 ) 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

142) Using Selenium IDE is it possible to get data from a particular html table cell ?

You can use the “storeTable” command

Example store text from cell 0,2 from an html table

storeTable

Css=#table 0.2

textFromCell

143) Explain what can cause a Selenium IDE test to fail?

  • 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

144)Mention why do you need Session Handling while working with Selenium?

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.

145 ) Mention what are the advantages of Using Git Hub For Selenium?

The advantages of Using Git Hub for Selenium are

  • 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.

146)What do we mean by Selenium 1 and Selenium 2?

Selenium RC and WebDriver, in a combination are popularly known as Selenium 2. Selenium RC alone is also referred as Selenium 1.

147) Which is the latest Selenium tool?

WebDriver

Q148) How do I launch the browser using WebDriver?

The following syntax can be used to launch Browser:
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();

Q149) What are the different types of Drivers available in WebDriver?

The different drivers available in WebDriver are:

  • FirefoxDriver
  • InternetExplorerDriver
  • ChromeDriver
  • SafariDriver
  • OperaDriver
  • AndroidDriver
  • IPhoneDriver
  • HtmlUnitDriver

Q150) What are the different types of waits available in WebDriver?

There are two types of waits available in WebDriver:

  • Implicit Wait
  • Explicit Wait

Implicit Wait: Implicit waits are used to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.

Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.

Q 151) How to type in a textbox using Selenium?

User can use sendKeys(“String to be entered”) to enter the string in the textbox.

Syntax:
WebElement username = drv.findElement(By.id(“Email”));
// entering username
username.sendKeys(“sth”);

152) How can you find if an element in displayed on the screen?

WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.

  • isDisplayed()
  • isSelected()
  • isEnabled()

Syntax:

isDisplayed():
boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed();

isSelected():
boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isDisplayed();

isEnabled():
boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();

Q153) How can we get a text of a web element?

Get command is used to retrieve the inner text of the specified web element. The command doesn’t require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages.

Syntax:

String Text = driver.findElement(By.id(“Text”)).getText();

154) What does a character class for all alphabetic characters and digits look like in regular expressions?

[a-zA-Z0-9] matches any alphanumeric character


155) What does a character class for all alphabetic characters and digits look like in globbing?

regexp: *[a-zA-Z0-9]

156) What must one set within SIDE in order to run a test from the beginning to a certain point within the test?

We need to set a break point in the test, so the test will pause at the break point.

157) . What does a right-pointing green triangle at the beginning of a command in SIDE indicate?

That triangle indicates that test paused at that step, or will start from that step.

158) . How does one get rid of the right-pointing green triangle?

Right click on that line and remove break point.

159) How can one add vertical white space between sections of a single test?

User can input comment line between test steps, and in the comment line, add spaces.

160) . What Selenium functionality uses wildcards?

Regular expression can use wildcards.

161) How much does Selenium license cost per client machine?
Selenium is open source software, released under the Apache 2.0 license and can be downloaded and used without charge.

162) Where to download Selenium?
Selenium can be downloaded and installed for free from seleniumhq.org

163) What is the latest version of Selenium?
The latest versions are Selenium IDE 1.3.0, Selenium Server (formerly the Selenium RC Server) 2.8.0, Selenium Client Drivers Java 2.8.0, Selenium Client Drivers C# 2.8.0, Selenium Client Drivers Ruby 2.8.0, Selenium Client Drivers Python 2.8.1, Selenium Grid 1.0.8.

164) What are the limitations of Selenium IDE?
Selenium IDE has many great features and is a fruitful and well-organized test automation tool for developing test cases, in the same time Selenium IDE is missing certain vital features of a testing tool: conditional statements, loops, logging functionality, exception handling, reporting functionality, database testing, re-execution of failed tests and screenshots taking capability. Selenium IDE doesn't for IE, Safari and Opera browsers.

165) What does SIDE stand for?
Selenium IDE. It was a very tricky interview question

166) What is Selenium Remote Control (RC) tool?
Selenium Remote Control (RC) is the powerful solution for test cases that need more than simple browser actions and linear execution. Selenium-RC allows the developing of complex test scenarios like reading and writing files, querying a database, and emailing test reports. These tasks can be achieved by tweaking test cases in your preferred programming language.

167) What are the advantages using Selenium as testing tool?
If QA Tester would compare Selenium with HP QTP or Micro Focus SilkTest, QA Engineer would easily notice tremendous cost savings for Selenium. In contrast to expensive SilkTest license or QTP license, Selenium automation tool is absolutely free. It means that with almost no investment in purchasing tools, QA Team could easily build the state of the art test automation infrastructure. Selenium allows developing and executing test cases in various programming languages including .NET, Java, Perl, RubyPython, PHP and even HTML. This is a great Selenium advantage, most likely your software developers already know how to develop and maintain C# or Java code, so they transfer coding techniques and best practices to QA team. Selenium allows simple and powerful DOM-level testing and in the same time could be used for testing in the traditional waterfall or modern Agile environments. Selenium would be definitely a great fit for the continuous integration tools Jenkins, Hudson, CruiseControl, because it could be installed on the server testing box, and controlled remotely from continuous integration build.

168) How many browsers are supported by Selenium IDE?
Test Engineer can record and playback test with Selenium IDE in Firefox.

169) Can Selenium test an application on iPhone's Mobile Safari browser?
Selenium should be able to handle Mobile Safari browser. There is experimental Selenium IPhone Driver for running tests on Mobile Safari on the iPhone, iPad and iPod Touch

170)For which browser selenium support etc?
Firefox, Internet Explorer, Safari, chrome etc.

171) Which language selenium support?
To enhance the automated test cases Java, C#, PHP, Python, Perl, Ruby etc.are used. Java is most used used in automated testing.

172) When selenium was launched?
Selenium was launched in 2001.

173) When selenium webdriver was launched?
Selenium webdriver was launched in 2006.

174) When Selenium 2 is launched?
Selenium 2 was launched in 2008. It is merged with webdriver and RC

175) Which are the part of Selenium 1?
Selenium 1 consist IDE (Integrated Development Environment), RC and selenium grid

176) Which are the part of Selenium 2?
Selenium 2 consist IDE (Integrated Development Environment), RC (Remote Control), Webdriver and selenium grid

177) What are the drwaback of selenium IDE?
It supports only Mozila Firefox not other browsers. It doesn’t support flow control statement, programming language and complicated programs. It doesn’t support random test cases.

178) What is data driven test cases?
Data driven test cases means executing test cases using multiple test case data

179) What is selenium RC (Remote Control)?
Rc support execution of test cases and multiple languages like java, c#, perl, php, python etc. It support random test cases. It support varius browser and flow control and control program

180) What are the testing framework used in selenium?
Junit (helps to execute test batches and generate test report) and TestNG (used to execute test suite and parallel testing).

181)What is the difference between driver.close() and driver.quit()?

driver.close(): It is used to close the browser or page currently in focus.
driver.quit(): It is used to shutdown the webdriver and close all instances associated to webdriver.

182) What are locators?

Locators can be termed as address to elements on the page, which makes possibility to identify element uniquely on the page.

183) What are the different locators available in Selenium WebDriver?

Following are the different types of locators available in Selenium WebDriver :-
1). ID
2). Name
3). ClassName
4). Xpath
5). CSS Selector
6). LinkText
7). PartialLink Text
8). TagName

184) What is the xpath?
XPaththeXML Path language, is a query language for selecting nodes from an XML document.
It enables to traverse through every node across the entire page and help in finding element with reference to another element on Page.

185) What are starts-with() and contains()function in xpath?
XPaththestarts-with():It is used when starting path is static & end part is dynamic
Syntax : //*[starts-with(@id, ”)]/a
XPaththecontains():It is used when middle path is static & starting and end part is dynamic
Syntax : //*[contains(@id, ”)]/a
XPaththeends-with():It is used when ending path is static & starting part is dynamic
Syntax : //*[ends-with(@id, ”)]/a

186) What is the difference between ‘/’ and ‘//’ ??

It is used to search in the entire structure.
/: It is used to identify the immediate child.

187) Why ID is most preferable way to identify the elements?

Using the ID attribute is most preferable way to identify the element.
W3C recommends that every developer should provide id attribute to elements which are unique on the page.
While processing the DOM(Document Object Model), browsers use id as the preferred way to identify the element and this provides the fastest locator strategy

188) What is the difference between findElement() and findElements() methods?

findElement() :This method return a webelement object based on specified search criteria or throws up an exception if it does not find any element matching the search criteria.
findElements() :This method returns a list of WebElements matching the search criteria. If no elements are found, it returns an Empty List.

189) If a Selenium function requires a pattern argument, what five prefixes might that argument have?
glob, regexp, exact, regexpi

190) What is the regular expression sequence that loosely translates to "anything or nothing?"
(.* i.e., dot star) This two-character sequence can be translated as “0 or more occurrences of any character” or more simply, “anything or nothing.

191) What is the globbing sequence that loosely translates to "anything or nothing?
(*) which translates to “match anything,” i.e., nothing, a single character, or many characters.

192) . What does a character class for all alphabetic characters and digits look like in regular expressions?
[0-9] matches any digit
[A-Za-z0-9] matches any alphanumeric character
[A-Za-z] matches any alphabet character

193) . What does a character class for all alphabetic characters and digits look like in globbing?
[0-9] matches any digit
[a-zA-Z0-9] matches any alphanumeric character
[a-zA-Z] matches any alphabet character

194) What must one set within SIDE in order to run a test from the beginning to a certain point within the test?
Set Toggle BreakPoint.

195)What is WebDriver?

WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application

196) Can Selenium test a application on iPhone’s Mobile Safari browser?

Selenium can handle Mobile Safari browser. There is experimental Selenium IPhone Driver for running tests on Mobile with Safari on the iPhone and iPad and iPod Touch.

197) . What are the disadvantages of Selenium? Disadvantages of Selenium:

Limitation in terms of browser support (It runs only in Mozilla).Scripts written using Selenium IDE can be used for other browsers only if it is used with Selenium RC or Selenium Core. We can’t run recorded script if it is converted to Java, C#, Ruby etc. Not allowed to write manual scripts like conditions and Loops for Data Driven Testing There is no option to verify images

198) Explain what is Datadriven framework and Keyword driven?

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. Keyworddriven framework: The keyword driven frameworks requires the development of data tables and keywords, independent of the test automation. In a keyword driven test, the functionality of the application under test is documented in a table as well as step by step instructions for each test.

199) What are the features of TestNG and list some of the functionality in TestNG which makes it more effective?

TestNG is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs, from unit testing to integration testing. And the functionality which makes it efficient testing framework are Support for annotations Support for data-driven testing Flexible test configuration Ability to re-execute failed test cases

200) What Selenese command can be used to display the value of a variable in the log file, which can be very valuable for debugging?
echo()

Selenium Interview Questions 1

Selenium Interview Questions 2

Selenium Interview Questions 3

Selenium Interview Questions 4