Interview Questions and Answers For Selenium Webdriver You May Want To Know

Question 1: What is Selenium?

Selenium as the most famous automation testing suites is made to support functional automation test for web applications. You can run selenium testing script in all popular web browsers and various operating system. It is totally open source and free. Selenium suite is a package which include numerous test tools. Each tool is designed for different purposes.

Question 2: What testing types that selenium testing support

Selenium testing support following two types. 1. Functional Test. 2. Regression Test.

Question 3: Why you choose selenium as your automation testing tool?

  1. It is open source and totally free with a lot of helping resource and a large developer based community.
  2. Support a lot of popular web browser such as Chrome, Safari, Firefox, Internet Explorer etc.
  3. Support popular operating system such as Windows, Linux and Max OS.
  4. Support a number of popular programming languages (Java, Python, C#, Php, Ruby, Perl etc).
  5. Support distributed automation testing.
  6. Regular and consistency version release.

Question 4: Please describe different test tools in selenium testing suite.

The testing suite includes four test tools in general:

  1. Selenium IDE ( Integrated Development Environment ) : is a Firefox Plugin which is used to record and playback test case steps into selenium testing scripts.

    You can click here to find out tutorials about how to use Selenium IDE.
  2. Selenium WebDriver : is a tool which can be used to operate web browser directly and automatically in your program. Each web browser has it’s own webdriver executable software. Such as InternetExplorerDriver.exe, ChromeDriver.exe, SafariDriver.exe and GeckoDriver.exe(For Firefox web browser). Those drivers play as a proxy between your selenium testing scripts and web browser. Your selenium testing command was sent to those driver server, then those driver server call the related web browser to perform the actions such as click, input text, submit etc.

    You can find a lot of webdriver tutorials by click here.
  3. Selenium RC ( Remote Control) : is an automation testing tool that can help you to write selenium testing script to test web based applications in almost any coding language towards any kind of HTTP web site make use of any popular JavaScript-enabled web browser.

    There are two parts in selenium RC:
    Server Part: This part is used to launch, quit or do any interaction with web browsers automatically. It listen to the client request, when receive any client request then send these requests to related web browsers.

    Client Part: Client part includes several libraries for different coding language. You can use these library to interact with server part in your selenium testing script.

    Selenium RC is perfect for testing complicated AJAX-based web applications within Continuous Integration system.

  4. Selenium Grid : You can make your selenium testing execution distributed on multiple machines and platforms simultaneously.

Question 5 : Limitations of Selenium?

  1. It can only be used to test web applications for automation test.
  2. You can only use Junit or TestNG to generate reports in selenium testing.

Question 6 : When will you use Selenium IDE?

The IDE should be the easiest tool in the package. It is used to record and playback test steps in test cases. It is extremely easy to learn.You do not need any programming background. So you can use it when you just need to record test steps in test case. You can export recorded test script to any programming language you are familiar with.

Question 7: What automation testing is and what benefits can you get from automation testing?

Automation testing is to run test cases automatically use test automation tools. You can use testing tools to write test scripts that can be run repeatedly without any manual involvement.

You can get following benefits from testing automation:

  1. Run test cases repeatedly.
  2. Run large test cases quickly and accurate.
  3. Parallel execute large test case.
  4. Increase testing accuracy and decrease tester produced errors.
  5. Save testing time and money.

Question 8: Different browsers support between Selenium IDE, RC and Webdriver?

  1. Selenium IDE support Firefox only because it is a Firefox plugin.
  2. Selenium RC support Chrome, Firefox, Safari, Internet Explorer etc.
  3. Webdriver support Chrome, Firefox, Safari, Internet Explorer etc. Support HtmlUnit also which is a headless browser.

Question 9: Which component has Record and Playback feature

Only Selenium IDE has Record and Playback feature, Selenium RC and Webdriver does not has those features.

Question 10: Which component has server requirement?

Only Selenium RC require server started before running selenium testing scripts. Selenium IDE and Webdriver do not require.

Question 11: Can you describe architecture of each Selenium component?

Selenium IDE and RC are all javascript based while Webdriver uses web browser’s native interface.

Question 12: Which component supports mobile automation testing?

Only Webdriver support mobile automation testing use such as iPhoneDriver, AndroidDriver etc.

Question 13: Which component runs faster in automation testing

Selenium IDE runs fast because it is a Firefox plugin, when your test script execute, the plugin also runs. The IDE communicates with Firefox directly.

WebDriver is also much faster because it communicates with browsers directly.

Selenium RC is the slowest one in the testing tool suites because it sends selence commands to Selenium Core which actually ‘talks’ to the web browser. Selenium RC does not communicate with the web browser directly.

Question 14: What is Selenese?

Selenese is script language used to write selenium testing scripts in Selenium Integrate Develope Environment.

Question 15: Do you know the various kinds of locators in Selenium?

Locator is used to identify web page elements in webpage. There are different kinds of locators to find web page elements precisely and accurately, they are:

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

Question 16: When should Selenium Grid be used?

When you need to run same or different selenium testing scripts on multiple web browsers or operating systems simultaneously then you can use Selenium Grid to accomplish this. With that you can make the selenium testing execution distributed in different testing environments and save a lot of execution time.  

Question 17: Tell the difference between Selenium 1 and Selenium 2 and which is the newest?

Selenium 1 only includes Selenium RC. Selenium 2 includes Selenium RC and Webdriver. Selenium 2 is the newest one.

Question 18: How can you start web browsers using WebDriver?

You can use related web browser’s initiation class to launch a web browser. Following is some sample codes.

 //Firefox web browser initiation class
 WebDriver firefoxDriver = new FirefoxDriver();
 //Chrome web browser initiation class
 WebDriver chromeDriver = new ChromeDriver();
 //Internet Explorer web browser initiation class
 WebDriver ieDriver = new InternetExplorerDriver();

Question 19: Please list all the Driver types in WebDriver

  1. ChromeDriver
  2. FirefoxDriver
  3. SafariDriver
  4. OperaDriver
  5. InternetExplorerDriver
  6. HtmlUnitDriver
  7. AndroidDriver
  8. IPhoneDriver

Question 20: Describe the difference between Implicit Wait and Explicit Wait

Implicit Wait: It is a waiting time (suggest 30 seconds by default) among each selenium testing step throughout the entire selenium test script. Therefore, upcoming testing step will wait 30 seconds to execute after the previous test step’s execution.

Explicit Wait: It is used to pause the execution of current testing step until a certain state is reached or the maximum wait time has past. Explicit waits time are used to a specific instance only.

Question 21: How can you type text into text box using Webdriver?

User can use sendKeys(“String to be entered”) to enter the string in the text box.

sendKeys(“Input text”) is used to enter string text into textbox. For example.

 WebElement emaillAddress = driver.findElement(By.id(“EmailAddress”));
 // entering email address
 emaillAddress.sendKeys(“[email protected]”);

Question 22: How to get a web element’s text?

You can use getText method to retrieve a web element’s inner text. The method do not need any parameter and return string value.

 //Get text of a web element whose id is email
 String Text = driver.findElement(By.id(“email”)).getText();

Question 23: How to check whether a web element is shown on the screen or not?

You can use below methods to check web elements’ visibility. Web elements include buttons, radio buttons, checkboxes, drop boxes, labels etc.

isEnabled()
isSelected()
isDisplayed()

Examples:

 //isDisplayed():
 boolean submitButtonDisplayed = firefoxDriver.findElement(By.id(“SubmitUserInfoBtn”)).isDisplayed();
 //isSelected():
 boolean submitButtonSelected = firefoxDriver.findElement(By.id(“SubmitUserInfoBtn”)).isSelected();
 //isEnabled():
 boolean submitButtonEnabled = firefoxDriver.findElement(By.id(“SubmitUserInfoBtn”)).isEnabled();

Question 24: How can you choose value in dropdown list?

You can use Select class in WebDriver to select a value from drop down list.

 //selectByValue:
 Select selectDropDownByValue = new Select(fireFoxDriver.findElement(By.id(“Color_List_One”)));
 selectDropDownByValue.selectByValue(“redcolor”);
 //selectByVisibleText:
 Select selectDropDownByVisibleText = new Select (fireFoxDriver.findElement(By.id(“Color_List_Two”)));
 selectDropDownByVisibleText.selectByVisibleText(“green”);
 //selectByIndex:
 Select selectDropDownByIndex = new Select(fireFoxDriver.findElement(By.id(“Color_List_Three”)));
 selectDropDownByIndex.selectByIndex(2);

Question 25: How can you use linkText to click a hyperlink?

You can use following code to locate web element using link text.

//Use link text to locate a url link.
 fireFoxDriver.findElement(By.linkText(“www.dev2qa.com”)).click();
 //Use a partial link text to locate a url link
 fireFoxDriver.findElement(By.partialLinkText(“dev2qa.com”)).click();

Question 26: Describe each navigation methods in WebDriver.

fireFoxDriver.navigate().to(String url) : Start a new web browser and navigate to the url.

fireFoxDriver.navigate().back() : Take user back to the previous webpage in web browser history.

fireFoxDriver.navigate().refresh() : Reload all the web elements in current webpage to refresh it.

fireFoxDriver.navigate().forward() : Take user to the next webpage in web browser history.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.