Saturday September 15, 2018
Easily prepare for the 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 that 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:
Q 4. Name some automation tools which are used for application testing?
Automation tools used for application testing are
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:
Q 7. What are the advantages of using Selenium?
Below are the advantages of using Selenium:
Q 8. When will you choose to use Selenium Grid?
When there are multiple tests to be executed, we will use the selenium grid.
It will enable us to run some 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:
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:
|1.||Google Chrome||Chrome Driver|
|2.||Mozilla Firefox||Firefox Driver|
|3.||Internet Explorer||Internet Explorer Driver|
Q 11. Name the types of testing in Selenium?
Selenium supports the following types of testing that are:
Q 12. Name the different ways to find an element in a web page using Selenium?
Every object on a web page is referred to as an element in selenium. These can be found using different ways such as:
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 a record and playback feature that we can use to run tests repeatedly in the same sequence.
Q 15. What is X Path in Selenium?
X Path is a locator that 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.
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.
|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 that need to be pass in Selenium. These are listed below:
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
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:
|1.||isEnabled()||boolean searchIconEnabled = driver.findElement(By.id(“trial”)).isEnabled();|
|2.||isSelected()||boolean buttonSelected =
|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:
|1.||selectByValue||Select selectByValue = new Select(driver.findElement(By.id(“One”)));
|2.||selectByVisibleText||Select selectByVisibleText = new Select (driver.findElement(By.id(“Two”)));
|3.||selectByIndex||Select selectByIndex = new Select(driver.findElement(By.id(“Three”)));
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.
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.
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.
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 are 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 on how many test cases were passed, failed or skipped.
Q 36. Are you familiar with the 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 the 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:
|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:
Q 43. How would you delete the cookies using Selenium?
To delete the cookies, we will use the deletedAllCookies() command.
Q 44. Write the code to double-click an element?
|Actions action = new Actions(driver);
WebElement element = driver.findElement(By.id(“elementId”));
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:
Q 46. How will you perform drag and drop in Selenium?
|Actions action = new Actions(WebDriver);
Q 47. Which command will you use to retrieve the color of an element in Selenium?
We will use the following command:
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?
The source view shows the script in XML format.
Q 50. How will you verify whether the element is visible or not?
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