DEV Community

Code Green
Code Green

Posted on

Selenium Interview Question and Answers

👉 Download our Selenium | Java | Python | Interview app with 1000+ questions for Automation Testers Download From Play Store


Question: What is Automation Testing?
Answer: Automation testing is a process of automating the manual
process to test the application/system. Automation testing involves the
use of a separate testing tools which lets you create test scripts which
can be executed repeatedly and doesn't require any manual
intervention.


Question: What Testing types are supported by selenium?
Answer: Functional Testing and Regression Testing


Question: What are the limitations of Selenium?
Answer: Following are the limitations of Selenium:

  1. Selenium supports testing of only web-based applications
  2. Mobile applications cannot be tested using Selenium
  3. Captcha and Barcode readers cannot be tested using Selenium
  4. Reports can only be generated using third-party tools like TestNG or JUnit.
  5. As Selenium is a free tool, thus there is no ready vendor support through the user can find numerous helping communities.
  6. The user is expected to possess prior programming language knowledge.

Question: What are the different types of locators in Selenium?
Answer: The locator is used to identify a web element uniquely within
the webpage. Thus, to identify web elements, we have different types
of locators in Selenium:

  1. ID
  2. ClassName
  3. Name
  4. TagName
  5. LinkText
  6. PartialLinkText
  7. Xpath
  8. CSS Selector

Question: What is the difference between assert and verify commands?
Answer: 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 halt i.e. any failure during verification would
not stop the execution and all the test steps would be executed.


Question: What is an XPath?
Answer: XPath is used to locate a web element based on its XML path.
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.


Question: Relative and absolute xpath?
Answer: Absolute Xpath: It contains the complete path from the Root
Element to the desire element. Single slash(/) is used to create Xpath
with absolute path
Relative Xpath: This is more like starting simply by referencing the
element you want and go from the particular location. Double slash(//)
is used to represent Xpath with relative path


Question: How to launch the browser in selenium WebDriver?
Answer: Webdriver is an interface so, We cannot instantiate directly
but we can create a reference of it as below:
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();
FirefoDriver, ChromeDriver, InternetExplorerDriver etc are different
browser classes in selenium. By using above syntax, we can launch a
browser


Question: How to type in a textbox using Selenium?
Answer: The user can use sendKeys() method to enter the string in the
textbox.
Syntax:
WebElement username = driver.findElement(By.id(uname));
username.sendKeys(sth);


Question: How to ensure if element is present on screen?
Answer: By using isDisplayed(), we can ensure if webelement is
present/visible on webpage


Question: How to get Text of particular webelement?
Answer: getText() is used to retrieve the inner text of the specified
web element. It returns a string value.
Syntax:
String Text = driver.findElement(By.id(Text)).getText();


👉 Download our Selenium | Java | Python | Interview app with 1000+ questions for Automation Testers Download From Play Store


Top comments (0)