• info@testbytes.net
  • +91 811 386 5000
whatsapp

Top 50 Selenium Interview Questions and Answers 2018

selenium interview questions

Easily prepare for Selenium interview with our detailed list of over 50 questions and answers.

These interview questions are solely designed to serve the purpose to enrich you with knowledge.

These sample questions are meant for both beginners and professionals that will help them to become more advanced and knowledgeable to face any typical interview.

Q 1. What is Selenium?

Selenium is a WebDriver automation tool which is used to test web-based applications via automating the test procedure. It

supports various browsers, programming languages, and platforms.

Q 2. What is Automation Testing?

Automation Testing is a procedure for automating the manual steps or process to test the application or software.

It requires an additional testing tool to create test scripts that can be executed repeatedly.

Q 3. What are the advantages of automating the test procedure?

 Advantages of automation testing are:

  • Improvement in accuracy by eliminating human-generated errors
  • Efficient and time-saving process
  • Helps in testing a large application
  • Tests can be repeatedly executed
  • Allows another test to run simultaneously
  • Provides test reports automatically

Q 4. Name some automation tools which are used for application testing?

Automation tools used for application testing are

  • Selenium
  • TestingWhiz
  • Katalon
  • Tosca Testsuite
  • TestComplete
  • Ranorex

Q 5. Why do we need software testing?

 Once an application is developed, it is mandatory to check whether that application contains any errors or not.

Software testing provides a tester to check for substantial errors or bugs in the application and resolves it.

Q 6. Explain different components of Selenium?

Selenium consists of four components:

  • Selenium Web Driver: It is used for automation testing of web-based applications with browser’s class method.
  • Selenium Integrated Development Environment (IDE): It is a Firefox plugin used to record and playback test cases.
  • Selenium Remote Control (RC): Selenium RC works on JavaScript to automate test procedure for web applications.
  • Selenium Grid: It helps selenium to run different tests simultaneously.

Q 7. What are the advantages of using Selenium?

Below are the advantages of using Selenium:

  • It is an open source automation tool which is available freely without any licensing cost.
  • It supports multiple languages such as Java, Python, ruby etc.
  • It also supports various browsers.
  • It has a rich community which provides any type of information to any problem.
  • It is user-friendly and even a beginner can easily understand and write the automated scripts for the test.

Q 8. When will you choose to use Selenium Grid?

When there are multiple tests to be executed, we will use selenium grid.

It will enable us to run same test scripts on multiple platforms simultaneously and thus reducing the time consumption.

Q 9. Can you illustrate the drawbacks of Selenium?

Below are the drawbacks of Selenium:

  • It cannot be used for desktop applications testing.
  • Also, it cannot perform on test on web services.
  • To create vigorous scripts, knowledge of programming languages is required.
  • External libraries are required to perform tasks in Selenium.

Q 10. Name a few browsers that are supported by Selenium? Also, mention the name of the drivers.

Some common browsers supported by Selenium are:

Sr. No. Browsers Drivers
1. Google Chrome Chrome Driver
2. Mozilla Firefox Firefox Driver
3. Internet Explorer Internet Explorer Driver
4. Safari SafariDriver
5. HtmlUnit HtmlUnitDriver

 

Q 11. Name the types of testing in Selenium?

Selenium supports the following types of testing that are:

  • Regression Testing
  • Functional Testing
  • Load Testing

Q 12. Name the different ways to find an element in a web page using Selenium?

Every object in a web page is referred to as an element in selenium. These can be found using different ways such as:

  • ID
  • CSS Selector
  • Attribute
  • Linktext
  • Xpath
  • Name
  • DOM
  • ClassName
  • Tag, etc.

Q 13. Can you test APIs or web services using Selenium Web Driver and why?

No, we cannot test web services using Selenium. Web services are headless and it only uses browser’s class method to automate web applications. Thus it cannot automate web services.

Q 14. When will you choose to use Selenium IDE?

 When there is repetition in the test procedure and we want to run the same sequence over and over again. Thus, Selenium IDE provides record and playback feature which we can use to run tests repeatedly in the same sequence.

Q 15. What is X Path in Selenium?

X Path is a locator which uses XML path to locate a web element in Selenium.

It can also be used to locate HTML elements. X Path uses references from another element to find the specific element in a web page.

Q 16. Can you state the difference between Verify and Assert commands?

Verify: Verify command checks whether the given condition is true or not.

Whatever the results, the program execution will not be halt. Even if the given condition is false, the program execution will not be stopped.

Also Read : Top 25 Software Testing Companies to Look Out For in 2018

Assert: Assert command also check whether the given condition is true or not.

If the condition is true, the program will continue to execute to next step. But, if the given condition is false, it will immediately halt the execution of the program.

Q 17. Can you state the difference between the use of single slash (/) and a double slash (//) in X Path?

In X Path single slash is used to derive the absolute path from root node whereas double slash creates relative X Paths.

Q 18. What is the basic difference between absolute and relative X Path?

The basic difference between them is:

Absolute X Path: It uses a complete path starting from the node of the root element to go to the desired element.

Relative X Path: It only uses references from another element to go to the desired element.

Q 19. How will you launch the browser using Selenium Web Driver?

We will use the following syntax to launch the browser using Selenium Web Driver.

Sr. No Browser Syntax
1. Google Chrome WebDriver driver = new ChromeDirver();
2. Mozilla Firefox WebDriver driver = new FirefoxDriver();
3. Internet Explorer WebDriver driver = new InternetExplorerDriver();

Q 20. Can you name the parameters which you have to pass in Selenium?

Yes, there are four parameters which need to be pass in Selenium. These are listed below:

  • Port Number
  • Host
  • Browser
  • URL

Q 21. Have you ever automated test cases, If yes, how many per day?

Yes, I’ve automated test cases and on average I can automate 3-5 test cases each day. Although, these test cases can be sometimes complex and lengthy that can take a day to complete.

Q 22. Can we locate the elements by only using their text in XPath?

Yes, we can simply use the text() method to locate the element by using their text.

Syntax: xPathExpression = //*[text()=’username’]

Q 23. Can you name the latest Selenium tool and its use?

 WebDriver is the latest selenium tool used to automate web applications testing and checks whether it is working as expected or not.

Q 24. How will you type in a textbox using Selenium and also give the syntax?

To enter the text in the textbox, we can use sendkeys(“Enter desired string”). The syntax is given below:

WebElement username = drv.findElement(By.id(“Email”));

// entering username

username.sendKeys(“sth”);

Q 25. How will you find if an element is displayed on the screen?

 Web  Driver lets the user check the visibility of the web elements including labels, radio buttons, checkboxes, drop boxes etc. with the following methods:

Sr. No Command Syntax
1. isEnabled() boolean searchIconEnabled = driver.findElement(By.id(“trial”)).isEnabled();
2. isSelected() boolean buttonSelected =

driver.findElement(By.id(“trial”)).isSelected();

3. isDisplayed() boolean buttonPresence = driver.findElement(By.id(“trial”)).isDisplayed();

 Q 26. How can you launch different browsers in Selenium Web Driver?

We can easily use the given syntax to launch the multiple browsers:

WebDriver driver = new FirefoxDriver();

 Q 27. Can you state the difference between driver.get(“URL”) and driver.navigate().to(“URL”) command? What is the use of them?

Both commands are similar and hence there is no difference between them.

These commands are used to navigate to URL which is declared in the command.

Q 28. How will you select the value in a drop-down?

We can easily select the value in a dropdown using the syntax given below:

Sr. No. Command Syntax
1. selectByValue Select selectByValue = new Select(driver.findElement(By.id(“One”)));

selectByValue.selectByValue(“greenvalue”)

2. selectByVisibleText Select selectByVisibleText = new Select (driver.findElement(By.id(“Two”)));

selectByVisibleText.selectByVisibleText(“Lime”);

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

selectByIndex.selectByIndex(2);

 Q 29. When will you use findElement() and findElements()?

 findElement(): This command is used to fetch the first element of the current webpage which is matching to the specified locator value in the syntax.

Syntax:  WebElement element = driver.findElements(By.xpath(“//div[@id=’sample’]//ul//li”));

findElements(): This command is used to fetch all the elements of the current webpage which is matching to the specified locator value in the syntax.

Syntax: List <WebElement> elementList = driver.findElements(By.xpath(“//div[@id=’sample’]//ul//li”));

 Q 30. Can you state the difference between driver.close() and driver.quit() command?

driver.close(): This command is used to close the current web browser window opened by the user.

driver.quit(): This command is used to close all the web browser window opened by the user.

Also Read : 52 Software Tester Interview Questions That can Land You the Job

Both commands don’t need any parameters and do not return any value.

Q 31. Will Selenium be able to handle the windows based pop up if it shows up?

 No, Selenium is only meant for web-based applications thus it only supports web-based pop-ups.

Q 32. How will you assert the title on your web page?

With the use of given syntax, we can easily assert the title on a web page.

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

Q 33. How will you clear the text which is written in a textbox?

We will use clear() command to clear the text which is written in a text box.

Syntax: driver.findElement(By.id(“elementLocator”)).clear();

 Q 34. Can you state the difference between regression and functional testing?

Regression Testing: Regression testing is a repeated test of an already tested program.

Usually, it ensures to check the proper functioning of the application even if the minor modification is done that can create unexpected problems.

testbytes-mobile-app-testing-banner

Functional Testing: Functional testing usually ensures the functionality of the software program.

The design and user experience remain untouched as the goal of functional testing is only to check the functionality of the program.

Q 35. What is the use of TestNG in Selenium?

 TestNG in Selenium is used to cover a wide range of test categories such as functional, unit, end-to-end etc.

Using TestNG we can easily generate a proper report of test cases and can easily gather the information of how many test cases were passed, failed or skipped.

Q 36. Are you familiar with term GeckoDriver in Selenium? Why is it needed?

GeckoDriver is a web browser engine which forms a bridge between the Firefox browser and Selenium to interact with each other.

GeckoDriver is needed in Selenium because, until Firefox version 47, Selenium uses the Firefox driver to interact with the browser. Now, Firefox has introduced a new version starting from version 48 that won’t allow any third party to directly interact with the browser.

Thus, Selenium version 3 uses the driver to interact and run tests with the Firefox browser (version 48 onwards) which is GeckoDriver.

Q 37. Can we verify the image using Selenium?

No, we cannot verify the image in Selenium but we can easily verify whether the image is displayed or not using properties.

Q 38. Can you state the difference between ‘Type’ and ‘TypeAndWait’ command?

Type: When the user needs to enter the text into a text field, type command is used.

TypeAndWait: This command is generally used to reload the web page as soon as the typing of text is completed.

Q 39. What are the different types of mouse actions supported by Selenium?

Following are the various mouse actions which are supported by Selenium:

Sr.No Syntax
1. click(WebElement element)
2. contextClick(WebElement element)
3. doubleClick(WebElement element)
4. mouseUp(WebElement element)
5. mouseDown(WebElement element)
6. mouseMove(WebElement element)
7. mouseMove(WebElement element, long xOffset, Long, yOffset

Q 40. Do you know who developed the Selenium and in which year?

It was Jason Huggins who developed the Selenium in the year 2004.

Q 41. How will you take screenshots using Selenium?

We can easily take screenshot using TakeScreenShot function with getScreenshotAs() method. Example:

File scrFile = ((TakeScreenshot)driver).getScreenshotAs(screenshot.JPG);

Q 42. Can you go back and forth in the browser using Selenium?

Yes, we can easily use the following commands to move back and forth in the browser using Selenium:

  • navigate().back()
  • navigate().forward()

Q 43. How would you delete the cookies using Selenium?

To delete the cookies, we will use deletedAllCookies() command.

Syntax: driver.manage().deleteAllCookies();

Q 44. Write the code to double-click an element?

Actions action = new Actions(driver);

WebElement element = driver.findElement(By.id(“elementId”));

action.doubleClick(element).perform();

 Q 45. Can you list all the navigations methods which are used in Selenium?

Yes, the following are the different navigation methods use in Selenium:

Sr. No. Syntax
1. driver.navigate().to(String url);
2. driver.navigate().refresh();
3. driver.navigate().forward();
4. driver.navigate().back();

Q 46. How will you perform drag and drop in Selenium?

Actions action = new Actions(WebDriver);

action.dragAndDrop(sourceWE, destWE)

 Q 47. Which command will you use to retrieve the color of an element in Selenium?

We will use the following command:

getCssValue(“Color”)

getCssValue(“Background-color”)

Q 48. Which command will you use to copy the file from one location to another location?

We will use FileUtils.copyFile(srcLocation, destLocation) to copy the file from one location to another location.

Q 49. In what format the source view shows the script in Selenium IDE?

 Source view shows the script in XML format.

Q 50. How will you verify whether the element is visible or not?

app testing

To verify whether the element is visible or not, we’ll use following syntax:

WebElement e = driver.findElement();

boolean result = e.isDisplayed();

Recommended For You : Top 10 Mobile App Testing Companies In India

Testbytes