Top 50 Selenium Interview Questions You Must Prepare 27.Jul.2024

Q1. Give Selenium Ide Tool Disadvantage?

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

Q2. What Is The Difference Between Single And Double Slash In Xpath?

/

  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

 

Q3. If One Wanted To Display The Value Of A Variable Named Answer In The Log File, What Would The First Argument To The Previous Command Look Like?

echo()

Q4. How To Developer Selenium Test Cases?

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.

Q5. What Is The Use Of Context Menu In Selenium Ide?

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

Q6. What Is The Selenium's Recording Language?

Selenium’s recording language is “HTML”.

Q7. How Do You Verify An Object Presented In Multiple Pages?

Check on each page

  assertTrue(selenium.isElementPresent(locator));

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

Q9. What Is Selenium Ide?

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.

Q10. Which Is The Command Used For Displaying The Values Of A Variable Into The Output Console Or Log?

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

 

Q11. What Are The Features Of Selenium Ide ?

  • 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

 

Q12. Explain About Selenium-ide ?

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

Q13. In Selenium Ide, Give The Usage Of Context Menu?

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

Q14. How To Insert A Breakpoint In Selenium Ide?

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

Q15. What Are Heightened Privileges Browsers?

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

Q16. Define Selenium 2.x?

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

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

Q18. What Is The Price Of Selenium License Per Server?

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

Q19. Explain About Selenium-grid ?

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.

Q20. I Have Created My Own Firefox Profile; Can I Execute My Test Scripts On It

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"

Q21. What Does Side Stand For?

Selenium IDE. It was a very tricky interview question.

Q22. How To Run Test Case Traced By Employing Ide In Browsers?

Selenium remote control is used in this case.

Q23. Is There A Way For Me To Know All Available Options When I Start Selenium Server?

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.

Q24. How Recorded Command Can Be Edited In Ide?

First select and choose interested value from drop-down.

Q25. What Are The Advantages And Disadvantages Of Selenium ?

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

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

Q27. How Do I Upload A File Using Selenium? I Need To Upload A Word File During Test Execution.

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.

Q28. How Do You Set User Extensions In Selenium Ide?

  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.

Q29. What Programming Languages Can You Use In Selenium Rc?

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

Q30. What Programming Language Is Best For Writing Selenium Tests?

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.

Q31. Explain Selenium Waitfor Commands ?

  • 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

Q32. Do You Know Any Alternative Test Automation Tools For Selenium?

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.

Q33. How Do You Capture An Element Loading After The Page Load?

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);  }  }

Q34. What Is Selenium Webdriver?

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.

Q35. What Does A Right-pointing Green Triangle At The Beginning Of A Command In Side Indicate?

Play Entire Test Suite

Q36. Describe Technical Problems That You Had With Selenium Tool?

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.

Q37. Which Selenium Command(s) Simulates Selecting A Link?

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

Q38. My Application Uses Ajax Heavily How Do I Use Selenium Rc To Work With Ajax Operations?

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);  }

Q39. What Are The Advantages And Disadvantages Of Using Selenium As Testing Tool?

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.

Q40. What Are The Advantage And Features Of Selenium Ide?

  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

 

Q41. What Test Can Selenium Do?

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.

Q42. How To Insert A Comment In Selenium Ide?

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>

Q43. What Are The Steps To Run Automation Using Selenium?

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.

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

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

Q46. Which Are The Browsers Supported By Selenium Ide?

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

Q47. What Is Selenium-rc (remote Control) ?

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.

Q48. Give Ide's Main Parts And Components?

  • Target
  • Command and
  • Value

Q49. I Am Not Able To Use "style" Attribute To Locate Element With Ie Browser?

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

Q50. What Are The Test Types Supported By Selenium?

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