Top 50 Selenium Interview Questions You Must Prepare 19.Mar.2024

  • The selenium IDE tool works only in Mozilla Firefox browser
  • Multiple windows are not played when it is recorded.

/

  1. start selection from the document node
  2. allows you to create 'absolute' path expressions
  3. example “/html/body/p” matches all the paragraph elements

//

  1. start selection matching anywhere in the docume
  2. allows you to create 'relative' path expressions
  3. example. “//p” matches all the paragraph elements

 

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.

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

Selenium’s recording language is “HTML”.

Check on each page

  assertTrue(selenium.isElementPresent(locator));

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.

Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and 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. Selenium-IDE also offers full editing of test cases for more precision and control.

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 ${variable name}

example: echo ${var1}

Note: Here var1 is the variable

 

  • Record and playback
  • Intelligent field selection will use IDs, names, or XPath as needed
  • Auto complete for all common Selenium commands
  • Walk through test cases and test suites.
  • Debug and set breakpoints
  • Save texts as HTML, Ruby scripts, or other formats
  • Support for Selenium user-extensions.js file
  • Option to automatically assert the title of every page
  • Rollup common commands

 

  • Selenium IDE is an integrated development environment for Selenium tests.
  • Operates as a Firefox add-on and provides an 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.
  • It also has a context menu (right-click) integrated with the Firefox browser, which allows the user to pick from a list of assertions and verifications for the selected location.
  • Offers full editing of test cases.
  • Although it is a Firefox only add-on, tests created in it can also be run against other browsers by using Selenium-RC & specifying the name of the test suite on the command line.

It permits user to select from assertions and verifications list for chosen specific location.

Break point can be set in two ways in Selenium IDE

  1. Right click on the command in Selenium IDE and select "Toggle BreakPoint"
  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

Firefox and IE have browser modes which are not restricted by java script’s same origin policy. These browsers are known as browsers with elevated security privileges. In case of Firefox it is known as chrome (It’s not the Google browser) and in case of IE it is known as iehta

It is the next generation selenium. It is selenium server-web driver that replaces Selenium RC.

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.

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

Selenium-Grid allows the Selenium-RC solution to scale for test suites or test suites to be run in multiple environments.

With Selenium-Grid multiple instances of Selenium-RC are running on various operating system and browser configurations, each of these when launching register with a hub. When tests are sent to the hub they are then redirected to an available Selenium-RC, which will launch the browser and run the test.

This allows for running tests in parallel, with the entire test suite theoretically taking only as long to run as the longest individual test.

You may like to create your own firefox profile because Selenium always created a clean firefox profile while executing the tests and none of your FF settings and plug-in are considered with this clean profile. If you want to execute tests on FF with your settings then you should create custom profile for FF.

To be able to execute tests on a custom firefox profile you should specify its path while starting Selenium server. For example if your new profile is stored at “awesome location” in your directory then you should start Selenium server as following–

Java –jar .jar -firefoxProfileTemplate "awesome location"

Selenium IDE. It was a very tricky interview question.

Selenium remote control is used in this case.

If you want to see all options available while starting Selenium server then you should use option “-h” while starting Selenium server

Java –jar .jar –h

It would display you all the options which you can use while starting the Selenium server.

First select and choose interested value from drop-down.

Advantages

  • Supports C#, Java, PHP, Perl, Python
  • Supported on Windows, Linux and Mac OS
  • Highly active developer community - backed by Google
  • Powerful methods to locate elements (Xpath, CSS, DOM)

Disadvantages

  • Challenges running on browsers other than Firefox
  • Difficulty to automate AJAX
  • Limitations to automate Applets, MS and Desktop Applications

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

If you are using Firefox then you can use “type” command to type in a File Input box of upload file. But type operation does not work with IE and you would have to use “Robot” class in java to work make file upload work.

  1. Open user-extensions.js with an editor (Notepad, etc.); it's found in the seleniumcorescripts folder. If it doesn't exist, just create it.
  2. If you need to, commit the user-extensions.js file (like if you use subversion).
  3. Open Selenium IDE and choose the Options menu and then Options... from that menu.
  4. Make sure the path to your user-extensions.js file is entered in the Selenium Core extensions field (like seleniumcorescriptsuser-extensions.js)
  5. Press OK button on options
  6. Restart the IDE to reflect your extensions.

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

  • waitForPageToLoad : This command will make the script to wait till the page loads.Syntax is waitForPageToLoad(timeout); Timed out is the maximum time the script will wait for the page to load.
  • waitForAlert : This command will wait for the alert message to appear
  • waitForTable: This command will wait for the Web table to completely load in the page
  • waitForTitle: This command will for the page Title to appear on the browser.
  • Other waitFor commands : Selenium has several other wait command like waitForText,waitForPopup and so on. These commands are generically called Synchronization commands

Selenium appears to be the mainstream open source tool for browser side testing, but there are many alternatives. Canoo Webtest is a great Selenium alternative and it is probably the fastest automation tool. Another Selenium alternative is Watir, but in order to use Watir QA Tester has to learn Ruby. One more alternative to Selenium is Sahi, but is has confusing interface and small developers community.

provide a time to check the element( in seconds) Like :

public void waitForElementPresent(String element, int timeout) throws Exception   {  for (int second = 0;; second++)  {  if (second >= timeout)  fail("Timeout.Unable to find the Specified element"+element);  try   {     if (selenium.isElementPresent(element)) break;  }   catch (Exception e) { }  Thread.sleep(1000);  }  }

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.

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.

click, clickandWait, ClickAt, ClickAtandWait, DoubleClick, DoubleClickandWait, doubleClickAt,
doubleClickAtandWait

Ajax operations don’t reload a page like normal form submission but they make http requests behind the scene. You cannot use waitForPageToLoad for such operations and instead should use conditional wait for change in state of application. This could as well mean waiting for presence of an element before continuing with test operations. Consider following example in which type operation triggers Ajax operation which is followed by conditional wait for presence of a text box

// type operation brings element “q” on screen without loading the page

  selenium.type("elementLocator","testData");  // conditional wait for element “q”  for(intsecond = 0;; second++) {  if(second >= 60) fail("timeout");  try {if(selenium.isElementPresent("q"))break;}catch(Exception e){}  Thread.sleep(1000);  }

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.

  1. Intelligent field selection will use IDs, names, or XPath as needed
  2. It is a record & playback tool and the script format can be written in various languages including C#, Java, PERL, Python, PHP, HTML
  3. Auto complete for all common Selenium commands
  4. Debug and set breakpoints
  5. Option to automatically assert the title of every page
  6. Support for Selenium user-extensions.js file

 

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.

Comments in Selenium IDE can be set in two ways

  1. Right click on the command in Selenium IDE and select "Insert New Comment"
  2. If you want to comment an existing line. You need to follow the below mentioned steps.
    1. Select the source tab in IDE
    2. Select the line which you want to comment
    3. Assume that if you want to comment a open command you need to write like below mentioned code
  <tr>   <!--   <td>open&l/td>  <td>/node/304/edit&l/td>  <td></td>  -->  </tr>

The very basic steps are:

  1. Record the test steps using selenium-IDE.
  2. Modify the script according to the testing needs. Add validation points, Java Scripts, Time-out etc.
  3. Run the test.
  4. View the result after test run complete analyze.

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

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.

Selenium IDE supports only one browser Mozilla Firefox. The versions supported as of now are:

Mozilla Firefox 2.x
Mozilla Firefox 3.x

The versions not supported as of now are:

earlier versions of Mozilla Firefox 2.x
Mozilla Firefox 4.x

Selenium-RC provides an API (Application Programming Interface) and library for each of its supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby. Selenium-RC allows the test automation developer to use a programming language for maximum flexibility and extensibility in developing test logic.

For instance, if the application under test returns a result set, and if the automated test program needs to run tests on each element in the result set, the programming languages iteration support can be used to iterate through the result set, calling Selenium commands to run tests on each item.

This is because IE expects attribute values to be in caps while other browsers expect it to be lower case letters. Hence

//tr[@style="background-color:yellow"] works with other browsers
//tr[@style="BACKGROUND-COLOUR:yellow"] works with IE

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