selenium interview questions

Selenium Interview Questions and Answers

Q.What is Selenium?

Answer:  Selenium is a suite of tools for browser automation. It is composed of “IDE”, a recording and playback mechanism, “WebDriver” and “RC” which provide APIs for browser automation in a wide variety of languages, and “Grid”, which allows many tests using the APIs to be run in parallel. It works with most browsers, including Firefox from 3.0 up to 7, Internet Explorer 8, Google Chrome, Safari and Opera 11.5

Q.What is Automation Testing?

Answer: Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves use to a separate testing tool which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.

Q.What are the benefits of Automation Testing?

Answer: Benefits of Automation testing are:

Supports execution of repeated test cases

Aids in testing a large test matrix

Enables parallel execution

Encourages unattended execution

Improves accuracy thereby reducing human generated errors

Saves time and money

Q.what is Selenium and what is composed of?

Answer: Selenium is a suite of tools for automated web testing. It is composed of Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back. It is a firefox plugin

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

Q.What is Selenium IDE?

Answer:  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.

Q.What is the use of context menu in Selenium IDE?

Answer:  It allows the user to pick from a list of assertions and verifications for the selected location.

Q.Why should Selenium be selected as a test tool?

Answer:

Selenium is free and open source

Selenium have a large user base and helping communities

Selenium have cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.)

Selenium have great platform compatibility (Windows, Mac OS, Linux etc.)

It supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)

It has fresh and regular repository developments

It supports distributed testing.

Q.Can tests recorded using Selenium IDE be run in other browsers?

Answer:  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.

Q.What are the advantage and features of Selenium IDE?

Answer:  1. Intelligent field selection will use IDs, names, or XPath as needed

  1. It is a record & playback tool and the script format can be written in various languages including

C#, Java, PERL, Python, PHP, HTML

  1. Auto complete for all common Selenium commands
  2. Debug and set breakpoints
  3. Option to automatically assert the title of every page
  4. Support for Selenium user-extensions.js file

Q.What are the disadvantage of Selenium IDE tool?

Answer:  1. Selenium IDE tool can only be used in Mozilla Firefox browser.

  1. It is not playing multiple windows when we record it.

Q.What is Selenium RC (Remote Control)?

Answer:  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.

Q.How can we handle windows based pop up?

Answer: Selenium is an automation testing tool which supports only web application testing, that means, it doesn’t support testing of windows based applications. However Selenium alone can’t help the situation but along with some third party intervention, this problem can be overcome. There are several third party tools available for handling window based pop ups along with the selenium like AutoIT, Robot class etc.

Q.What is Selenium Grid?

Answer:  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.

Q.How Selenium Grid works?

Answer:  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.What you say about the flexibility of Selenium test suite?

Answer:  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.

Q.What test can Selenium do?

Answer:  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

Q.What is the cost of Selenium test suite?

Answer:  Selenium test suite a set of open source software tool, it is free of cost.

Q.What browsers are supported by Selenium Remote Control?

Answer:  The test automation expert can use Firefox, IE 7/8, Safari and Opera browsers to run tests in Selenium Remote Control.

Q.What programming languages can you use in Selenium RC?

Answer:  C#, Java, Perl, PHP, Python, Ruby

Q.What are the advantages and disadvantages of using Selenium as testing tool?

Answer:  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; can not test client server applications.

Q.What is difference between QTP and Selenium?

Answer:  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.

Q.What is difference between Borland Silk test and Selenium?

Answer:  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.

Silk Test uses 4Test scripting language. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.

Q.Describe technical problems that you had with Selenium tool?

Answer:   As with any other type of test automation tools like SilkTest, HP QTP, Watir, Canoo Webtest, Selenium allows to record, edit, and debug tests cases. However there are several problems that seriously affect maintainability of recorded test cases, occasionally Quality Assurance Engineers complain that it takes more time to maintain automated test cases than to perform manual testing; however this is an issue with all automated testing tools and most likely related to improper testing framework design. Another problem is complex ID for an HTML element. If IDs is auto-generated, the recorder test cases may fail during playback. The work around is to use XPath to find required HTML element. Selenium supports AJAX without problems, but QA Tester should be aware that Selenium does not know when AJAX action is completed, so ClickAndWait will not work. Instead QA tester could use pause, but the snowballing effect of several ‘pause’ commands would really slow down total testing time of test cases. The best solution would be to use waitForElement.

Q.What are the testing types that can be supported by Selenium?

Answer:  Selenium supports the following types of testing:

Functional Testing

Regression Testing

Q.What are the different types of waits available in WebDriver?

Answer:  There are two types of waits available in WebDriver:

1.Implicit Wait

2.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.What are the limitations of Selenium?

Answer:  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.

Q.When should I use Selenium IDE?

Answer:  Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.

Q.How do I launch the browser using WebDriver?

Answer:  The following syntax can be used to launch Browser:

WebDriver driver = new FirefoxDriver();

WebDriver driver = new ChromeDriver();

WebDriver driver = new InternetExplorerDriver();

Q.What is Selenese?

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

Q.When should I use Selenium Grid?

Answer:  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.

Q.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.How to type in a textbox using Selenium?

Answer:  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”);

Q.How can you find if an element in displayed on the screen?

Answer:  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.

1.isDisplayed()

2.isSelected()

3.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();

Q.Can you explain the phase of Automation Testing LifeCycle?

Outline the potential benefits and test tool proposal

Test tool evaluation and selection

Steps necessary to outline automated testing to the project

Identifies the test procedure standards, defines the tests, defines development standard

Test plans are executed

This is done throughout the life­cycle

Q.What are the different types of locators in Selenium?

Answer:  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

Q.What are the different types of Drivers available in WebDriver?

Answer:  The different drivers available in WebDriver are:

FirefoxDriver

InternetExplorerDriver

ChromeDriver

SafariDriver

OperaDriver

AndroidDriver

IPhoneDriver

HtmlUnitDriver

Q.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.What are the steps to run automation using selenium?

Ans: The very basic steps are:

Record the test steps using selenium­IDE.

Modify the script according to the testing needs. Add validation points, Java Scripts,

Time­out etc.

Run the test.

View the result after test run complete analyze.

Q.What are the capabilities of Selenium IDE?

Answer:  Selenium IDE (Integrated Development Environment) works similar to commercial tools like QTP, Silk Test and Test Partner etc.

The below points describes well about Selenium IDE.

Selenium IDE is a Firefox add­on.

Selenium IDE can support recording the clicks, typing, and other actions to make a test cases.

Using Selenium IDE, a tester can play back the test cases in the Firefox browser.

Selenium IDE supports exporting the test cases and suites to Selenium RC.

Debugging of the test cases with step­by­step can be done.

Breakpoint insertion is possible.

Page abstraction functionality is supported by Selenium IDE.

Selenium IDE can supports an extensibility capability allowing the use of add­ons or user extensions that expand the functionality of Selenium IDE

Q.How to find more than one web element in the list?

Answer:  At times, we may come across elements of same type like multiple hyperlinks, images etc arranged in an ordered or unordered list. Thus, it makes absolute sense to deal with such elements by a single piece of code and this can be done using WebElement List.

Sample Code

// Storing the list

List elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

Fetching the size of the list int listSize = elementList.size(); for (int i=0; i {

  • Clicking on each service provider link serviceProviderLinks.get(i).click();
  • Navigating back to the previous page that stores link to service providers driver.navigate().back();

}

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

Answer:  close(): WebDriver’s close() method closes the web browser window that the user is currently working on or we can also say the window that is being currently accessed by the WebDriver. The command neither requires any parameter nor does is return any value.

quit(): Unlike close() method, quit() method closes down all the windows that the program has opened. Same as close() method, the command neither requires any parameter nor does is return any value.

Q.How can we get a text of a web element?

Answer:   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(); 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. How to select value in a dropdown?

Value in the drop down can be selected using WebDriver’s Select class.

Syntax:

SelectByValue:

Select selectByValue = new Select(driver.findElement(By.id(“SelectID_One”)));

selectByValue.selectByValue(“greenvalue”);

selectByVisibleText:

Select selectByVisibleText = new Select

(driver.findElement(By.id(“SelectID_Two”)));

selectByVisibleText.selectByVisibleText(“Lime”);

selectByIndex:

Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));

selectByIndex.selectByIndex(2);

Q.What are the different types of navigation commands?

Answer:  Following are the navigation commands:

navigate().back() – The above command requires no parameters and takes back the user to the previous webpage in the web browser’s history. Sample code:

driver.navigate().back();

navigate().forward() –

This command lets the user to navigate to the next web page with reference to the browser’s history.

Sample code:

driver.navigate().forward();

navigate().refresh() –

This command lets the user to refresh the current web page there by reloading all the web elements.

Sample code:

driver.navigate().refresh();

navigate().to() –

This command lets the user to launch a new web browser window and navigate to the specified URL.

Sample code:

driver.navigate().to(“https://google.com”);

Q.How to get title?

driver.getTitle();~To Print: System.out.println( driver.getTitle());

Q.Can Selenium handle windows based pop up?

Answer:  Selenium is an automation testing tool which supports only web application testing.

Therefore, windows pop up cannot be handled using Selenium.

Q.Can WebDriver test Mobile applications?

WebDriver cannot test Mobile applications. WebDriver is a web based testing tool, therefore applications on the mobile browsers can be tested.

Q.How can we handle web based pop up?

WebDriver offers the users with a very efficient way to handle these pop ups using Alert interface. There are the four methods that we would be using along with the Alert interface.

void dismiss()  The accept() method clicks on the “Cancel” button as soon as the pop up window appears.

void accept() The accept() method clicks on the “Ok” button as soon as the pop up window appears.

String getText() The getText() method returns the text displayed on the alert box.

void sendKeys(String stringToSend)  The sendKeys() method enters the specified string pattern into the alert box.

Syntax:

// accepting javascript alert

Alert alert = driver.switchTo().alert();

alert.accept();

Q.What test can Selenium do?

Answer:  Selenium could be used for the functional, regression, load testing of the web based applications. The automation tool could be implemented for post release validation with continuous integration tools like Jenkins, Hudson, QuickBuild or CruiseControl.

Q.What is the price of Selenium license per server?

Answer:  Selenium is open source software, released under the Apache 2.0 license and can be downloaded and used without charge.

Q.How much does Selenium license cost per client machine?

Answer:  Selenium is open source software, released under the Apache 2.0 license and can be downloaded and used without charge.

Q.Where to download Selenium?

Answer:  Selenium can be downloaded and installed for free from seleniumhq.org

Q.What is the latest version of Selenium components?

Answer:  The latest versions are Selenium IDE 1.3.0, Selenium Server (formerly the Selenium RC Server) 2.9.0, Selenium Client Drivers Java 2.9.0, Selenium Client Drivers C# 2.9.0, Selenium Client Drivers Ruby 2.8.0, Selenium Client Drivers Python 2.9, Selenium Grid 1.0.8.

Q.What is Selenium IDE?

Answer:  Selenium IDE is a Firefox add-on that records clicks, typing, and other actions to make a test cases, which QA Tester can play back in the Firefox browser or export to Selenium RC. Selenium IDE has the following features: record/play feature, debugging with step-by-step and breakpoints, page abstraction functionality, an extensibility capability allowing the use of add-ons or user extensions that expand the functionality of Selenium IDE

Q.What are the limitations of Selenium IDE?

Answer:  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.

Q.What does SIDE stand for?

Ans: Selenium IDE. It was a very tricky interview question.

Q.What is Selenium Remote Control (RC) tool?

Answer:  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.

Q.What are the advantages using Selenium as testing tool?

Answer:  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.

Q.What is Selenium Grid?

Answer:  Selenium Grid extends Selenium RC to distribute your tests across multiple servers, saving you time by running tests in parallel.

Q.What is Selenium WebDriver?

Answer:  Selenium WebDriver is a tool for writing automated tests of websites. It is an API name and aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application. Selenium WebDriver is the successor of Selenium Remote Control which has been officially deprecated.

Q.How many browsers are supported by Selenium IDE?

Answer:  Test Engineer can record and playback test with Selenium IDE in Firefox.

Q.Can Selenium test an application on iPhone’s Mobile Safari browser?

Answer:  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.

Q.Can Selenium test an application on Android browser?

Answer:   Selenium should be able to handle Android browser. There is experimental Selenium Android Driver for running tests in Android browser.

Q.What are the disadvantages of using Selenium as testing tool?

Answer:  Selenium weak points are tricky setup; dreary errors diagnosis; tests only web applications

Q.How many browsers are supported by Selenium Remote Control?

Answer:  QA Engineer can use Firefox 7, IE 8, Safari 5 and Opera 11.5 browsers to run actuall tests in Selenium RC.

Q.How many programming languages can you use in Selenium RC?

Answer:  Several programming languages are supported by Selenium Remote Control – C# Java Perl PHP Python Ruby

Q.How many testing framework can QA Tester use in Selenium RC?

Answer:  Testing frameworks aren’t required, but they can be helpful if QA Tester wants to automate test cases. Selenium RC supports Bromine, JUnit, NUnit, RSpec (Ruby), Test::Unit (Ruby), TestNG (Java), unittest (Python).

Q.How to developer Selenium Test Cases?

Answer:  Using the Selenium IDE, QA Tester can record a test to comprehend the syntax of Selenium IDE commands, or to check the basic syntax for a specific type of user interface. Keep in mind that Selenium IDE recorder is not clever as QA Testers want it to be. Quality assurance team should never consider Selenium IDE as a “record, save, and run it” tool, all the time anticipate reworking a recorded test cases to make them maintainable in the future.

Q.What programming language is best for writing Selenium tests?

Answer:  The web applications may be written in Java, Ruby, PHP, Python or any other web framework. There are certain advantages for using the same language for writing test cases as application under test. For example, if the team already have the experience with Java, QA Tester could always get the piece of advice while mastering Selenium test cases in Java. Sometimes it is better to choose simpler programming language that will ultimately deliver better success. In this case QA testers can adopt easier programming languages, for example Ruby, much faster comparing with Java, and can become become experts as soon as possible.

Q.Compare HP QTP vs Selenium?

Answer:  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.

Q.How to test Ajax application with Selenium

Answer:  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

Q.What are the technical challenges with selenium?

Answer:  As you know Selenium is a free ware open source testing tool. There are many challenges with Selenium.

  1. Selenium Supports only web based applications
  2. It doesn’t support any non web based (Like Win 32, Java Applet, Java Swing, .Net Client Server etc) applications
  3. When you compare selenium with QTP, Silk Test, Test Partner and RFT, there are many challenges in terms of maintainability of the test cases
  4. Since Selenium is a freeware tool, there is no direct support if one is in trouble with the support of applications
  5. There is no object repository concept in Selenium, so maintainability of the objects is very high
  6. There are many challenges if one have to interact with Win 32 windows even when you are working with Web based applications
  7. Bitmap comparison is not supported by Selenium
  8. Any reporting related capabilities, you need to depend on third party tools
  9. You need to learn any one of the native language like (.Net, Java, Perl, Python, PHP, Ruby) to work efficiently with the scripting side of selenium

Q.What are the test types supported by Selenium?

Answer:  Selenium could be used for testing the web based applications. The test types can be supported are:

  1. functional,
  2. regression,
  3. load testing

The automation tool could be implemented for post release validation with continuous integration tools like:

  1. Jenkins,
  2. Hudson,
  3. QuickBuild
  4. CruiseCont

Q.What are the capabilities of Selenium IDE?

Answer:  Selenium IDE (Integrated Development Environment) works similar to commercial tools like QTP, Silk Test and Test Partner etc. The below mentioned points describes well about Selenium IDE.

  1. Selenium IDE is a Firefox add-on.
  2. Selenium IDE can support recording the clicks, typing, and other actions to make a test cases.
  3. Using Selenium IDE A Tester can play back the test cases in the Firefox browser
  4. Selenium IDE supports exporting the test cases and suites to Selenium RC.
  5. Debugging of the test cases with step-by-step can be done
  6. breakpoint insertion is possible
  7. Page abstraction functionality is supported by Selenium IDE
  8. Selenium IDE can supports an extensibility capability allowing the use of add-ons or user extensions that expand the functionality of Selenium IDE

Selenium Interview Questions            Selenium Interview Questions and Answers

Q.How to execute a single line command from Selenium IDE?

Answer:  Single line command from Selenium IDE can be executed in two ways

  1. Right click on the command in Selenium IDE and select “Execute This Command”
  2. Select the command in Selenium IDE and press “X” key on the keyboard
  3. How to insert a start point in Selenium IDE?

Start point Selenium IDE can be set in two ways

  1. Right click on the command in Selenium IDE and select “Set / Clear Start Point”
  2. Select the command in Selenium IDE and press “S” key on the keyboard
  3. You can have only one start point
  4. If you have already set one start point and you selected other command as start point. Then the first start point will be removed and the new start point will be set
  5. Right click on the command in Selenium IDE and select “Inert New Comment”
  6. If you want to comment an existing line. You need to follow the below mentioned steps.
  7. Select the source tab in IDE
  8. Select the line which you want to comment
  9. Assume that if you want to comment a open command you need to write like below mentioned code

Q.How to click on a hyper link using linkText?

Answer:  driver.findElement(By.linkText(“Google”)).click();

The command finds the element using link text and then click on that element and thus the user would be re­directed to the corresponding page.

The above mentioned link can also be accessed by using the following command. driver.findElement(By.partialLinkText(“Goo”)).click();

The above command find the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.

Q.How to assert title of the web page?

//verify the title of the web page

assertTrue(“The title of the window is incorrect.”,driver.getTitle().equals(“Title of the page”));

Q.What is a framework?

Answer:  Framework is a constructive blend of various guidelines, coding standards, concepts, processes, practices, project hierarchies, modularity, reporting mechanism, test data injections etc. to pillar automation testing.

Q.How to handle frame in WebDriver?

Answer: An inline frame acronym as iframe is used to insert another document with in the current HTML document or simply a web page into a web page by enabling nesting. Select iframe by id

driver.switchTo().frame(“ID of the frame“);

Locating iframe using tagName

driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0)); Locating iframe using index

frame(index)

driver.switchTo().frame(0);

frame(Name of Frame)

driver.switchTo().frame(“name of the frame”);

Q.When do we use findElement() and findElements()?

Answer:  findElement(): findElement() is used to find the first element in the current web

page matching to the specified locator value. Take a note that only first matching

element would be fetched.

Syntax:

WebElement element =

driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

findElements():

findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements.

Syntax:

List elementList =

driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

Q.What are the advantages of Automation framework?

Answer:  Advantage of Test Automation framework

Reusability of code

Maximum coverage

Recovery scenario

Low cost maintenance

Minimal manual intervention

Easy Reporting

Q.How can I read test data from excels?

Answer: Test data can efficiently be read from excel using JXL or POI API

Q.Explain how Selenium Grid works?

Answer: 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.

Q.How to mouse hover on a web element using WebDriver?

Answer: WebDriver offers a wide range of interaction utilities that the user can exploit to automate mouse and keyboard events. Action Interface is one such utility which simulates the single user interactions.

Q.Can captcha be automated?

Answer: No, captcha and bar code reader cannot be automated.

Q.Explain what is assertion in Selenium and what are the types of assertion?

Answer: 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”..

Q.While using click command can you use screen coordinate?

Answer: 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)

Q.How to retrieve css properties of an element?

Answer: The values of the css properties can be retrieved using a get() method:

Syntax:

driver.findElement(By.id(“id“)).getCssValue(“name of css attribute”);

driver.findElement(By.id(“id“)).getCssValue(“font­size”);

Q.How to capture screen shot in WebDriver?

Answer: import org.junit.After;

import org.junit.Before;

import org.junit.Test;

import java.io.File;

import java.io.IOException;

import org.apache.commons.io.FileUtils;

import org.openqa.selenium.OutputType;

import org.openqa.selenium.TakesScreenshot;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class CaptureScreenshot {

WebDriver driver;

@Before

public void setUp() throws Exception {

driver = new FirefoxDriver();

driver.get(“https://google.com”);

}

@After

public void tearDown() throws Exception {

driver.quit();

}

@Test

public void test() throws IOException {

// Code to capture the screenshot

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

// Code to copy the screenshot in the desired location FileUtils.copyFile(scrFile, new File(“C:\\CaptureScreenshot\\google.jpg”));

}

}

Q.What is the difference between type keys and type commands ?

Answer: 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

Q.What is the difference between setSpeed() and sleep() methods? Both will delay the speed of execution.

Answer:  Thread.sleep () : It will stop the current (java) thread for the specified period of time. Its done only once

It takes a single argument in integer format Ex: thread.sleep(2000)­ It will wait for 2 seconds

It waits only once at the command given at sleep

SetSpeed () : For specific amount of time it will stop the execution for every selenium command.

It takes a single argument in integer format

Ex: selenium.setSpeed(“2000”)­ It will wait for 2 seconds

Runs each command after setSpeed delay by the number of milliseconds mentioned in set Speed

This command is useful for demonstration purpose or if you are using a slow web application

Q.What is same origin policy? How you can avoid same origin policy?

Answer: 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

Q.What is Object Repository? How can we create Object Repository in Selenium?

Answer:  Object Repository is a term used to refer to the collection of web elements belonging to Application Under Test (AUT) along with their locator values. Thus, whenever the element is required within the script, the locator value can be populated from the Object Repository. Object Repository is used to store locators in a centralized location instead of hard coding them within the scripts.

In Selenium, objects can be stored in an excel sheet which can be populated inside the script whenever required.

Q.What is Selenium and what is composed of?

Answer:  Selenium is a suite of tools for automated web testing. It is composed of

Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back. It is a firefox plugin

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

Q.How to insert a comment in Selenium IDE?

Answer: Comments in Selenium IDE can be set in two ways

  1. Right click on the command in Selenium IDE and select “Inert New Comment”
  2. If you want to comment an existing line. You need to follow the below mentioned steps.
  3. Select the source tab in IDE
  4. Select the line which you want to comment
  5. Assume that if you want to comment a open command you need to write like below mentioned code

Q.How to insert a break point in Selenium IDE?

Answer: Break point can be set in two ways in Selenium IDE

  1. Right click on the command in Selenium IDE and select “Toggle Break Point”
  2. Select the command in Selenium IDE and press “B” key on the keyboard
  3. If you want to clear the break point once again Spress “B” key on the keyboard
  4. You can set multiple break points in Selenium IDE

Q.How to debug the tests in Selenium IDE?

Answer: To debug or execute the test cases line by line. Follow the below mentioned steps

  1. Insert a break point (see the question to know more How to insert a break point in Selenium IDE? )from the location where you want to execute step by step
  2. Run the test case
  3. execution will be paused at the given break point
  4. Click on the step (Blue) button to continue with the next statement
  5. Click on Run button, to continue executing all the commands at a time

Q.How to export the tests from Selenium IDE to Selenium RC in different languages?

Answer: From selenium IDE the test cases can be exported into the languages

  1. .Net,
  2. Java,
  3. Perl,
  4. Python,
  5. PHP,
  6. Ruby

The below mentioned steps can explain how to export the test cases

  1. Open the test case from Selenium IDE
  2. Select File -> Export Test Case As
  3. How to export Selenium IDE Test Suite to Selenium RC Suites?

From selenium IDE the test suites can be exported into the languages as mentioned below

  1. .Net,
  2. Java,
  3. Perl,
  4. Python,
  5. PHP,
  6. Ruby

The below mentioned steps can explain how to export the test suites

  1. Open the test case from Selenium IDE
  2. Select File -> Export Test Suite As

Q.Which is the command used for displaying the values of a variable into the output console or log?

Answer: The command used for displaying the values of a variable into the output console or log – echo If you want to display a constant string. The below mentioned command can be used

echo

ex: echo “The sample message”

If you want to display the value of a variable it can be written like below

echo ${>

ex: echo ${var1}

Note: Here var1 is the variable

Q.Which are the browsers supported by Selenium RC?

Ans: Supported browsers for Selenium RC include:

  1. *firefox
  2. *mock
  3. *firefoxproxy
  4. *pifirefox
  5. *chrome
  6. *iexploreproxy
  7. *iexplore
  8. *firefox3
  9. *safariproxy
  10. *googlechrome
  11. *konqueror
  12. *firefox2
  13. *safari
  14. *piiexplore
  15. *firefoxchrome
  16. *opera
  17. *iehta
  18. *custom

Note: Any third party browser is supported with *custom followed by the complete path of the browser with executable

Q.Which are the Operating Systems supported by Selenium?

Answer: Selenium IDE  Works in Firefox 2+ Start browser, run tests Run tests

Operating Systems Supported:

  1. Windows,
  2. OS X
  3. Linux
  4. Solaris
  5. Others whichever supports Firefox 2+

Selenium Remote Control

Used for starting browser and run tests

Operating Systems Supported:

  1. Windows,
  2. OS X
  3. Linux
  4. Solaris
  5. Others

Selenium Core

Used for running tests

Operating Systems Supported:

  1. Windows,
  2. OS X
  3. Linux
  4. Solaris
  5. Others

Q.What is Selenium RC?

Answer:  Selenium-RC is the solution for tests that need a little more than just simple browser actions and a linear execution. Selenium-RC leverages the full power of programming languages, creating tests that can do things like read and write external files, make queries to a database, send emails with test reports, and practically anything else a user can do with a normal application. You will want to use Selenium-RC whenever your test requires logic not supported by running a script from Selenium-IDE

Q.Why Selenium RC is used?

Answer:  Selenium-IDE does not directly support:

  1. condition statements
  2. iteration
  3. logging and reporting of test results
  4. error handling, particularly unexpected errors
  5. database testing
  6. test case grouping
  7. re-execution of failed tests
  8. test case dependency
  9. capture screenshots on test failures

The reason behind why Selenium-IDE does not support the above mentioned requirements is IDE supports only HTML language. Using HTML language we cannot achieve the above mentioned requirements. Because HTML does not support conditional, looping and external source connectives.To overcome the above mentioned problems Selenium RC is used.

Since Selenium RC supports the languages .Net, Java, Perl, Python, PHP, and Ruby. In these languages we can write the programme to achieve the IDE issues

Q.What is Selenium WebDriver or Google WebDriver or Selenium 2.0?

Answer: WebDriver uses a different underlying framework from Selenium’s javascript Selenium-Core. It also provides an alternative API with functionality not supported in Selenium-RC. WebDriver does not depend on a javascript core embedded within the browser, therefore it is able to avoid some long-running Selenium limitations.

WebDriver’s goal is to provide an API that establishes

  • A well-designed standard programming interface for web-app testing.
  • Improved consistency between browsers.
  • Additional functionality addressing testing problems not well-supported in Selenium 1.0.

The Selenium developers strive to continuously improve Selenium. Integrating WebDriver is another step in that process. The developers of Selenium and of WebDriver felt they could make significant gains for the Open Source testautomation community be combining forces and merging their ideas and technologies. Integrating WebDriver intoSelenium is the current result of those efforts.

Q.What are the capabilities of Selenium WebDriver or Google WebDriver or Selenium 2.0?

Answer: One should use WebDriver when requiring improved support for

  • Mult-browser testing including improved functionality for browsers not well-supported by Selenium-1.0.
  • Handling multiple frames, multiple browser windows, popups, and alerts.
  • Page navigation.
  • Drag-and-drop.
  • AJAX-based UI elements. underlying framework from Selenium’s javascript Selenium-Core. It also provides an alternative API with functionality not supported in Selenium-RC. WebDriver does not depend on a javascript core embedded within the browser, therefore it is able to avoid some long-running Selenium limitations.

WebDriver’s goal is to provide an API that establishes

  • A well-designed standard programming interface for web-app testing.
  • Improved consistency between browsers.
  • Additional functionality addressing testing problems not well-supported in Selenium 1.0.

The Selenium developers strive to continuously improve Selenium. Integrating WebDriver is another step in that process. The developers of Selenium and of WebDriver felt they could make significant gains for the Open Source testautomation community be combining forces and merging their ideas and technologies. Integrating WebDriver intoSelenium is the current result of those efforts.

Q.What is the architecture of Selenium Grid?

Answer: The below mentioned theory explains about the setup of Selenium Grid with architecture and how it works.

Selenium Grid builds on the traditional Selenium setup, taking advantage of the following properties:

* The Selenium test, the application under test, and the remote control/browser pair do not have to be co-located. They communicate through HTTP, so they can all live on different machines.

* The Selenium tests and the web application under test are obviously specific to a particular project. Nevertheless, neither the Selenium remote control nor the browser is tied to a specific application. As a matter of fact, they provide a capacity that can easily be shared by multiple applications and multiple projects.

Consequently, if only we could build a distributed grid of Selenium Remote Controls, we could easily share it across builds, applications, projects – even potentially across organizations. Of course we would also need to address the scalability issues as described earlier when covering the traditional Selenium setup. This is why we need a component in charge of:

* Allocating a Selenium Remote Control to a specific test (transparently)

* Limiting the number of concurrent test runs on each Remote Control

* Shielding the tests from the actual grid infrastructure

Selenium Grid calls this component the Selenium Hub.

* The Hub exposes an external interface that is exactly the same as the one of a traditional Remote Control. This means that a test suite can transparently target a regular Remote Control or a Selenium Hub with no code change. It just needs to target a different IP address. This is important as it shields the tests from the gridinfrastructure (which you can scale transparently). This also makes the developer’s life easier. The same test can be run locally on a developer machine, or run on a heavy duty distributed grid as part of a build – without ever changing a line of code.

* The Hub allocates Selenium Remote Controls to each test. The Hub is also in charge of routing the Selenese requests from the tests to the appropriate Remote Control as well as keeping track of testing sessions.

* When a new test starts, the Hub puts its first request on hold if there is no available Remote Control in the grid providing the appropriate capabilities. As soon as a suitable Remote Control becomes available, the Hub will serve the request. For the whole time, the tests do not have to be aware of what is happening within the grid; it is just waiting for an HTTP response to come back.

Q.Does Selenium support mobile internet testing?

Answer: Selenium supports Opera. And opera is used in most of the Smart phones. So whichever Smart phone supports opera, selenium can be used to test. So, one can use Selenium RC to run the tests on mobiles.

For more details on supported browsers of Selenium Which are the browsers supported by Selenium RC?

Q.Does Selenium support Google Android Operating System?

Answer: Yes, Selenium Web Driver or Google Web Driver or Selenium 2.0 supports Android Operating System. There are several libraries written to support Android Operating System.

Fri, 07/15/2011 – 04:35 — Visitor

selenium android driver testing

try this …. this is cool … 😉

public class OneTest extends TestCase {

public void testGoogle() throws Exception {

AndroidDriver driver = new AndroidDriver();

// And now use this to visit Google

driver.get(“http://google.com”);

Thread.sleep(15000);

// Find the text input element by its name

WebElement element = driver.findElement(By.name(“q”));

// Enter something to search for

element.sendKeys(“hotmail”);

//driver.findElement(By.name(“q”)).sendKeys(“niloy.cit”);

// Now submit the form. WebDriver will find the form for us from the element

element.submit();

//driver.findElement(By.name(“btnG”)).click();

// Check the title of the page

System.out.println(“Page title is: ” + driver.getTitle());

driver.quit();

}

}

Q.What are the types of text patterns available in Selenium?

Answer: There are three types of patterns available in Selenium

  1. globbing
  2. regular expressions
  3. exact

Q.How to use regular expressions in Selenium?

Answer: Regular expressions in Selenium IDE can be used with the keyword – regexp: as a prefix to the value and patterns needs to be included for the expected values.

For example if you want to use the regular expression for a command

Command: verifyText

Target: //font/font/b/font[1]

Value: Flight Confirmation # 2011-05-02451

in the above example Flight Confirmation is continuously changing each time you run the test case. So this can be written with a regular expression as mentioned below

Command: verifyText

Target: //font/font/b/font[1]

Value: regexp:Flight Confirmation # [0-9]{4}-[0-9]{2}-[0-9]{5,10}

Q.What are the regular expression patterns available in Selenium?

Answer: Selenium regular expression patterns offer the same wide array of special characters that exist in JavaScript. Below are a subset of those special characters

PATTERN    MATCH

.    any single character

[ ]    character class: any single character that appears inside the brackets

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

|    alternation: the character/group on the left or the character/group on the right

( )    grouping: often used with alternation and/or quantifier

Q.What is Selenese?

Answer: Selenium set of commands which are used for running the test are called as Selenese.

There are three types of Selenese, those are:

  1. Actions – used for performing the operations and interactions with the target elements
  2. Assertions – used as check points
  3. Accessors – used for storing the values in a variable

Q.How do you add check points or verification points in Selenium?

Answer: check points or verification points are known as Assertions in Selenium. The keywords with below mentioned prefix will be used for adding check points or verification points.

  1. verify
  2. assert
  3. waitFor

Q.What is Assertion in Selenium?

Answer: Assertion is nothing but a check or verification point.

Assertion verifies the state of the application conforms to what is expected.

Examples include “make sure the page title is X” and “verify that this checkbox is checked.

Q.What are the types of Assertions there in Selenium?

Answer: Selenium Assertions can be used in 3 modes:

1) assert – When an “assert” fails, the test will be aborted. If you are executing test suite, the next state case will start

2) verify – When a “verify” fails, the test will continue execution, logging the failure.

3) waitFor – “waitFor” commands wait for some condition to become true (which can be useful for testing Ajaxapplications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting

Q.When to use Assert, Verify and WaitFor in Selenium?

Answer:  1) assert – If the expected value is mandatory to continue with the next set of steps we will use Assert. As Assert aborts the test, if the expected value doesn’t match. It is good to use for any mandatory checks.

2) verify – If the expected value is optional to continue with the next set of steps we will use Verify. As Verify continues executing with the next set of steps, if the expected value doesn’t match. It is good to use for any optional checks.

3) waitFor – If your test needs to wait, if the expected value is not matching we use waitFor. We normally use waitFor for AJAX kind of controls loading within a page

Q.What is an Accessor in Selenium?

Answer: Accessor is one of the type of Selenese.

  1. Accessors are used for storing the value of a target in a variable.

Ex:

1) storeTitle – Stores the title of a window in a variable

2) storeText – Stores the target element text in a variable

  1. Accessors are also used for evaluating the result and storing the result in a variable

Ex: storeTextPresent – Evaluates whether the text is present in the current window. If the text is present stores true in the variable else stores false

Ex: storeEementPresent – Evaluates whether the element is present in the current window. If the element is present stores true in the variable else stores false

Q.When to use Accessors in Selenium?

Answer: Accessors are mostly used for storing the value in a variable.

The variable can be used for following reasons:

1) To get the value from an element and comparing with some dynamic value

2) To take a logical decision to execute the test steps

ex: if the value of the variable true execute step1 and step2 else step3 and step4

3) To execute some statements in a loop based on the value returned by the element

Q.How to capture bitmaps in Selenium?

Answer:  Bitmaps are captured using the Selenium set of commands. There are two modes of capturing the bitmaps

1) Capture the bitmap for the entire page – it captures the browser main page area of AUT

2) Capture the bitmap for the screen shots – it captures the entire screen shot like the print scree that you give from your keyboard

Selenium doesn’t support bitmap capturing for an element on AUT.

Q.Which are the commands used for capturing the bitmaps?

Answer:  captureEntirePageScreenshot

Saves the entire contents of the current window canvas to a PNG file. Contrast this with the captureScreenshot command, which captures the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and is implemented in the RC only. Currently this only works in Firefox when running in chrome mode, and in IE non-HTA using the EXPERIMENTAL “Snapsie” utility. The Firefox implementation is mostly borrowed from the Screengrab! Firefox extension. Please see captureEntirePageScreenshot for more details

captureEntirePageScreenshotAndWait

Saves the entire contents of the current window canvas to a PNG file. Contrast this with the captureScreenshot command, which captures the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and is implemented in the RC only. Currently this only works in Firefox when running in chrome mode, and in IE non-HTA using the EXPERIMENTAL “Snapsie” utility. The Firefox implementation is mostly borrowed from the Screengrab! Firefox extension. Please see

captureEntirePageScreenshotAndWait for details.

Note: This command runs with only mozilla firefox when you run the tests from RC. Other browsers it will not support

Q.What is the difference between captureEntirePageScreenshot and CaptureScreenShot?

Answer: captureEntirePageScreenshot

  1. This captures the AUT web page only
  2. This supports only mozilla firefox
  3. Accepts two arguments. one is the file name to be saved and other argument is back ground color

CaptureScreenShot

  1. This captures the System screen shot
  2. This supports all the browsers when you run from Selenium RC
  3. Accepts one argument. That is the file name to be saved.

Q.What are the limitations of Selenium IDE?

Answer: The limitations of Selenium IDE are:

1) Selenium IDE uses only HTML language

2) Conditional or branching statements execution like using of if, select statements is not possible

3) Looping statements using is not possible directly in Selenium HTML language in ide

4) Reading from external files like .txt, .xls is not possible

5) Reading from the external databases is not possible with ide

6) Exceptional handling is not there

7) A neat formatted Reporting is not possible with ide

To eliminate the above issues we use Selenium RC

Q.What is heightened privileges browsers?

Answer: The purpose of heightened privileges is similar to Proxy Injection, allows websites to do something that are not commonly permitted. The key difference is that the browsers are launced in a special mode called heightened privileges. By using these browser mode, Selenium core can open the AUT directly and also read/write its content without passing the whole AUT through the Selenium RC server

Q.Why testers should opt for Selenium and not QTP?

Answer: Selenium is more popular than QTP as

Selenium is an open source whereas QTP is a commercial tool

Selenium is used specially for testing web based applications while QTP can be used for testing client server application also

Selenium supports Firefox, IE, Opera, Safari on operating systems like Windows, Mac, linux etc. however QTP is limited to Internet Explorer on Windows. Selenium supports many programming languages like Ruby, Perl, Python whereas QTP supports only VB script

Q.What are the four parameter you have to pass in Selenium?

Answer: Four parameters that you have to pass in Selenium are

Host

Port Number

Browser

URL

Q.How you can use “submit” a form using Selenium ? You can use “submit” method on element to submit form­ element.submit () ;

Alternatively you can use click method on the element which does form submission

Selenium IDE captures 3 options?

Command, Target, Value

Q.Mention what is the difference between Implicit wait and Explicit wait?

Answer: 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.

Explicit Wait : It is a one­timer, used for a particular search./p>

Q.What is Object Repository ?

Answer: An object repository is an essential entity in any UI automations which allows a tester to store all object that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

Q.Explain how to assert text of webpage using selenium 2.0 ?

Answer: WebElement el = driver.findElement(By.id(“ElementID”))

//get test from element and stored in text variable

String text = el.getText();

//assert text from expected

Assert.assertEquals(“Element Text”, text);

Q.Can we use Selenium grid for performance testing?

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

Q.Can Selenium test an application on Android browser?

Answer:  Selenium can handle Android browser.

Q.Which browsers does WebDriver support?

Answer: The existing drivers are the ChromeDriver, InternetExplorerDriver, FirefoxDriver, OperaDriver and HtmlUnitDriver. For more information about each of these, including their relative strengths and weaknesses, please follow the links to the relevant pages. There is also support for mobile testing via the AndroidDriver, OperaMobileDriver and IPhoneDriver

Q.What tests can selenium do?

Answer: Selenium could do functional, regression, and load of web based applications.p>

Q.Which attribute you should consider throughout the script in frame for “if no frame Id as well as no frame name”?

Answer: You can use…..driver.findElements(By.xpath(“//iframe”))….

This will return list of frames.

You will ned to switch to each and every frame and search for locator which we want. Then break the loop

Q.How do I execute Javascript directly?

Answer: We believe that most of the time there is a requirement to execute Javascript there is a failing in the tool being used: it hasn’t emitted the correct events, has not interacted with a page correctly, or has failed to react when an XmlHttpRequest returns. We would rather fix WebDriver to work consistently and correctly than rely on testers working out which Javascript method to call We also realise that there will be times when this is a limitation. As a result, for those browsers that support it, you can execute Javascript by casting the WebDriver instance to a JavascriptExecutor. In Java, this looks like:

WebDriver driver; // Assigned elsewhere

JavascriptExecutor js = (JavascriptExecutor) driver;

js.executeScript(“return document.title”);

Other language bindings will follow a similar approach. Take a look at the UsingJavascript page for more information.

Q.My XPath finds elements in one browser, but not in others. Why is this?

Answer: The short answer is that each supported browser handles XPath slightly differently, and you’re probably running into one of these differences. The long answer is on the XpathInWebDriver page..

Q.Explain what is the difference between find elements () and find element () ?

Answer:  find element ():

It finds the first element within the current page using the given “locating mechanism”. It returns a single WebElement

findElements () :

Using the given “locating mechanism” find all the elements within the current page.

It returns a list of web elements.

Q.Explain what are the JUnits annotation linked with Selenium?

Answer: The JUnits annotation linked with Selenium are

@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

@After public void method()­

To execute a method before this annotation is used, test method must start with test@Before

Q.Why is my Javascript execution always returning null?

Answer: ou need to return from your javascript snippet to return a value, so:

js.executeScript(“document.title”);

will return null, but:

js.executeScript(“return document.title”);

will return the title of the document.

Q.Can Selenium test a application on iPhone’s Mobile Safari browser?

Answer: 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.

Q.Explain what is Datadriven framework and Keyword driven?

Answer: 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.

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

Answer: 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

Q.Explain how you can login into any site if it’s showing any authentication popup for password and username?

Answer: Pass the username and password with url

Syntax­ http://username:password@url

ex­ http://creyate:abc@www.gmail.com

Q.What is the selenium’s recording language?

Answer: Selenium’s recording language is “HTML”.

Q.What does it mean to be “developer focused”?

Answer: We believe that within a software application’s development team, the people who are best placed to build the tools that everyone else can use are the developers. Although it should be easy to use WebDriver directly, it should also be easy to use it as a building block for more sophisticated tools. Because of this, WebDriver has a small API that’s easy to explore by hitting the “autocomplete” button in your favorite IDE, and aims to work consistently no matter which browser implementation you use.

contact for more on Selenium Online Training

Selenium Interview Questions Overall rating: ★★★★☆ 4.4 based on 427 reviews
5 1

selenium interview questions

Write A Review 

Name
Email
Review Title
Rating
Review Content

Selenium Interview Questions Tags

selenium interview questions and answers,selenium online training, selenium interview questions, selenium training online, selenium training, selenium training institute, latest selenium interview questions, best selenium interview questions 2019, top 100 selenium interview questions,sample selenium interview questions,selenium interview questions technical, best selenium interview tips, best selenium interview basics, selenium Interview techniques,selenium Interview Tips.

For  online training videos