• info@helpingtesters.com
  • helpingtesters

100+ Popular Selenium Interview Questions

October 16, 2017 Selenium Tutorial
Selenium Interview Questions, Selenium Interview Questions and answers, Selenium Questions

1. Difference between Selenium and QTP? (Important Selenium Interview Questions)

QTP UFT is the paid tool, whereas selenium is a Free tool.

  • QTP is used for both desktops as well as web-based applications, whereas selenium is used for only web-based applications.
  • QTP is easy to understand and much easier to work then on selenium as there are many features in QTP which makes it very useful. Ex: Run from Step is one of the features in QTP which is not there in selenium.

2. Tell about the brief introduction of Selenium?

There are 3 components in Selenium

  • WebDriver
  • IDE
  • Selenium GRID

IDE

  • It is a tool which gets added onto a Mozilla browser as an Add-on.
  • It generates no reports.
  • It is a very simple tool, which can be used for small-scale projects which as two or three pages which need to test on Mozilla browser.
  • Can’t use for complex projects.
  • Generates Test scripts in desired language.

WebDriver

  • It is a tool which supports multiple languages.
  • It supports multiple browsers
  • It generates reports
  • It can automate our application End to End.

GRID

  • It is used to run our tests in parallel.
  • It supports cross-browser testing remotely.

3. Does Selenium support Mobile Applications?

No, Selenium doesn’t support mobile applications.

4. Can we automate Client Server application through selenium?

No, we can’t automate client-server applications(desktop) through selenium.

5. Which type of testing can be done by using Selenium? (Important Selenium Interview Questions)

We can do Automation testing by using selenium, it is usually done on projects which are stable during the functional testing phase.

6. What are the limitations of Selenium IDE and Selenium WebDriver?

Selenium IDE

  • It works only on Mozilla.
  • It won’t generate reports.
  • It is a tool which can be used for simple applications.
  • Can’t used for complex applications, which has 1000 or more test cases, in this case, we can’t use IDE which is hard to parameterize.

Selenium WebDriver

  • It always works on the fresh browser, it can’t work on the browser which is already opened.
  • Selenium WebDriver is not at all fit to automate Ext-Js(Extended JavaScript) applications.
  • WebDriver has drivers for every browser if we talk about safari driver which is still unstable.
  • Selenium is used for only web-based applications, as it won’t support desktop applications as UFT.
  • It has only programming interface.
  • It can’t generate reports, need to depend on third-party tools.
  • The tester should have strong knowledge of programming language to write WebDriver Scripts.

7. What are the advantages and disadvantages of Selenium?

Advantages

  • It is a free tool
  • It operates on multiple operating systems like Unix, Linux etc….
  • It can integrate with other tools like SOAP UI for Rest Testing, it can integrate with Jmeter which is for load testing.
  • Can also integrate with CI tools like Jenkins.

Disadvantages

  • Selenium supports only web-based application and does not support windows based application.
  • Difficult to test Image-based applications.
  • It can’t generate reports, need to depend on third-party tools like TestNG or Jenkins.

8. Difference between the selenium1.0 and selenium2.0?

Selenium1.0 is selenium RC and Selenium2.0 is WebDriver.

  • Need to start the Remote server before execution from the command prompt in Selenium 1.0, whereas in Selnium2.0 there is no server which needs to start manually.
  • Selenium1.0 support some of the browsers like.. IE, FireFox, Chrome, and Opera. Can not support headless HTMLunit driver, whereas Selenium 2.0 supports all the browser like.. IE, FireFox, Chrome, Opera, headless HTMLunit, Android.

9. What is WebDriver?

WebDriver is an interface also known as selenium 2.0.It is one of the components in selenium suite of tools.

10. Tell about web driver architecture? (Important Selenium Interview Questions)

WebDriver directly communicates with browsers, there is no server in between WebDriver API and browsers. We write our test in Java using common selenium API and that Java binding will send commands to this common API. Now on the other end listening to a driver, it interprets those commands and executes them on the actual browser and return result backup using the API.

11. How to identify the elements? (Important Selenium Interview Questions)

By using locators like id, name, classname, CSS selector, linktext, partial linktext, DOM, and XPath we can identify the elements.

12. When should we go for Xpath?

When the elements are not found by the locators like id, class, name, etc. then XPath is used to find an element on the web page.

13. I want to run my application into the Firefox browser. How you handle it?

By creating the object of the FirefoxDriver.
Ex: WebDriver driver = new FirefoxDriver();

14. What is the difference between id and name?

Practically there is no difference, both id and name are two different locators or attributes given by the developer. They are uniquely used to identify the elements.

15. How to handle dynamic objects in selenium?

By making own customized XPath based on attributes we can handle dynamic objects in selenium.

16. What are the locators in selenium2.0?

Selenium2.0 have locators like id, name, classname, css selector, linktext, partial linktext, DOM and xpath.

17. What is the default timeout for selenium?

It is hardly close to zero.

18. What is the difference between implicit and explicit waits? (Important Selenium Interview Questions)

The implicit wait will be applied to all elements of a test case by default while explicit wait will be applied to targeted element only.

19. How to handle the Ajax applications in Web driver?

By applying different wait methods we can handle Ajax applications.

  • Thread.sleep()
  • Implicit Wait
  • Explicit Wait
  • Fluent Wait
  • WebdriverWait

20. How to handle the multiple windows in webdriver?

With the help of window handles, we can handle multiple windows in webdriver

21. Difference between findelement() and findelements()? (Important Selenium Interview Questions)

findelement() function will find the first element present on the page, whereas findelements() function will extract all the elements and put them on the list.

22. How to handle the alerts in webdriver?

By using driver.switchTo().alert()

23. How to take the screenshots in selenium2.0? (Important Selenium Interview Questions)

By using a class TakesScreenshot

Example:

File screenshotFile =((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

FileUtils.copyFile(screenshotFile,new File(“C:\\temp.png”));

24. How to handle the Bitmaps in selenium?

No, we can’t handle bitmaps in selenium, but if we want to handle images and read internal components we have to use java imaging API.

25. How do you upload/download files in selenium? (Important Selenium Interview Questions)

By using sendkeys() method and AutoIT tool we can upload files in selenium.

26. My checkbox would be in checked position, how can you say checkbox would be in check position?

By using getAttribute checked we can say checkbox is in checked position.

Example:

driver.findElement(By.xpath(“checkbox”)).getAttribute(“checked”);

27. My login page contains captcha explain how to write a script? (Important Selenium Interview Questions)

No, captcha cannot be handled by selenium.

28. How to run eclipse scripts from the command prompt by Ant?

We need to have build.xml with targets of compiling and running and we need to place all the jars at one location and you need to execute with the Ant.

29. How to execute the same script in different browsers?

We can open browsers dynamically by

WebDriver driver = null;

if(browser.equals(“Mozilla”);

driver= new FirefoxDriver();

else if(browser.equals(“Chrome”)) {

System.setProperty(“webdriver.chrome.driver”, ”F:\\chromedriver.exe”);

driver = new ChromeDriver();

}

30. What is the isDisplayed function?

isDisplayed function tells us whether the element is presently visible or it is hidden to the human eye or not.

31. What is the difference between isElementPresent and isDisplayed?

isElementPresent was a function in selenium RC which is not there in webdriver. It tells us whether the element is present on the page or not.

isDisplayed tells us whether the element is presently visible or it is hidden to the human eye or not.

32. Can you test flash images in selenium?

Yes, we can test flash images in selenium, but we need to have flash code of the application

33. How to verify an object presented in multiple pages?

By using the isElementPresent function we can verify whether an object is presented on the page.

34. How to select the third value from a drop-down in selenium 2.0?

By creating the object of the select class and pass over the object of drop-down from which we want to select.

Example:

Select s = new Select(driver.findElement(By.id(“”)));

s.selectByIndex(3);

35. Can Selenium support https protocols?

Yes, selenium supports https protocols.

36. How to handle the Ajax applications?

By using Explicit Wait and Implicit Wait, we can handle Ajax applications.

37.What is the command that can be used to enter values into text boxes?

By using sendkeys() command we can enter values into text boxes

38. How do you identify an object using selenium?

By using isElementPresent(String locator) we can identify an object using Selenium.

39. How can you run Selenium Server other than the default port 4444?

You can run Selenium server on java-jar selenium-server.jar-port other than its default port 4444.

40. How can you retrieve the message in an alert box?

By using storeAlert command we can retrieve the message of the alert pop up and store it in a variable.

41. Explain the difference between single and double slash in X-path?

Single slash ‘/ ’

  • Single slash ( / ) will start selection from the document node
  • It allows us to create ‘absolute’ path expressions

Double Slash ‘// ’

  • Double slash ( // ) will start selection matching anywhere in the document
  • It allows us to create ‘relative’ path expressions

42. What is the difference between verify and assert commands?

Both Assert and Verify commands allows checking whether an element is present on the page or not.

Assert: The test will be aborted on the step failed, if the asserted element is not available.

Verify: The test will continue executing and logs the failure when a verify command fails.

43. Tell me the difficulties faced by you in your project?

Object Identification

  • Ajax components-Explicit wait-browser based-separate code for browser
  • Variable XPath
  • Changing requirements and UI-properties file
  • Adding new tests to current project

44. Which driver implementation will allow headless mode? (Important Selenium Interview Questions)

HtmlUnitDriver will allow implementation of headless mode

45. How to drag and drop from one place to another place in webdriver?

By using ActionsClass we can drag and drop from one place to another place in webdriver.

46. How many types of frameworks are there?Which to use?How will you decide that?

There are 4 types of frameworks

  • Data Driven
  • Hybrid
  • POM+ pagefactory
  • Cucumber BDD

If our project is unstable then we use Data-driven

If our project is unstable and have similar pages on the website then we go for POM + pagefactory

If our project is stable then we go for Hybrid framework

47. Which tool did you use for reporting?

We can generate XSLT reports with TestNG, ANT, and Maven

48. Why did you choose selenium in your project where we had so many testing tools? (Important Selenium Interview Questions)

We choose selenium as

  • It is an open source tool
  • It is Platform independent tool.
  • It works on multiple browsers
  • It can integrate with CI tools like Jenkins.
  • It is a stable tool
  • Have lot of support available on internet about the tool
  • We can run selenium scripts parallelly using selenium-grid

49. How to click on an element which is not visible using Selenium WebDriver? (Important Selenium Interview Questions)

By using JavascriptExecutor we can click on an element which is not visible using selenium webdriver

50.What are the common exceptions you see in Selenium?

  • NoSuchElementException
  • StaleElementReferenceException
  • TimeoutException
  • ElementNotVisibleException
  • ElementNotSelectableException

51. What are the testing types that can be supported by Selenium

Selenium supports Functional Testing and Regression Testing

52. What are different wait mechanisms that can be used in scripting?

  • driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
  • WebDriverWait
  • Thread.sleep(3000);
  • FluentWait

53. What are the different ways of refreshing the browser?

  • Driver.navigate().refresh();
  • SendKeys – Keys.F5

54. What is the difference between Absolute path & Relative path?

Absolute path will start from root path(/), whereas Relative path will start from current path(//)

55. What is the difference between implicitly wait and Explicit wait?

Implicit wait will set internally a timeout which will be used for all consecutive web element searches.

The explicit wait is just one-timer which can be used for a particular search.

56. What is the difference between driver.Close() and driver.Quit () method?

driver.Close() is used to close the current Active window

driver.Quit() is used to close all the windows.

57. How can we run tests in multiple browsers in parallel?

By using selenium grid we can run parallel tests across multiple browsers and multiple platforms through remotely.

58. How do you clear the contents of a textbox in selenium?

By using a driver.clear() we can clear the contents of a textbox in selenium

59. How to refresh a page without using context click?

  • Using sendKeys.Keys method

Ex: driver.findElement(By.id(“id”)).sendKeys(Keys.F5);

  • Using navigate.refresh() method

Ex: driver.navigate().refresh();

  • Using get() method

Ex: driver.get(driver.getCurrentUrl());

60. What is the default time for selenium IDE and webdriver?

The default timeout for selenium ide and webdriver is 30 seconds.

61. List out the scenarios which we can’t automate?

Barcode Reader, captcha etc…are the scenarios which we can’t automate.

62. How do you handle alert pop-up? (Important Selenium Interview Questions)

Alert alert= driver.switchTo().alert(); // will move control to alert popup

alert.accept(); // to click on ok.

alert.dismiss(); // to click on cancel.

alert.getText(); // to capture alert message

alert.sendKeys(); // to pass the characters to popup

63. How to launch IE/chrome browser?

By setting the System property we can launch IE and Chrome browser

// To open IE browser

System.setProperty(“webdriver.ie.driver”,”path of the iedriver.exe file ”);

WebDriver driver = new InternetExplorerDriver();

//To open Chrome browser

System.setProperty(“webdriver.chrome.driver”,”path of the chromeDriver.exe file ”);

WebDriver driver = new ChromeDriver();

64. How can we perform right click using WebDriver?

By using Actions class we can perform right click in webdriver

Actions act = new Actions(driver).contextClick(webelement);

act.build().perform();

65. How will you click on a menu item in a drop-down list, if that menu has been created by using the select tag?

We use the methods selectByValue() or selectByIndex() or selectByVisibleText() to click on menu item in a drop down list if that menu has created by using select tag.

66. How will you click on a menu item in a drop-down, if that menu has not been created by using the select tag?

We can simply find the XPath of that element and click on drop down to select menu item

67. How do you simulate browser back and forward?

driver.navigate().back();

driver.navigate().forward();

68. What is the command used to get the current page URL?

driver.getCurrentUrl( ) is the command used to get current page Url.

69. How will you achieve synchronization in WebDriver?

By using implicit wait, we can achieve synchronization.

Syntax:

driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

70. What are the prerequisites to run selenium webdriver?

We require Java JDK, Eclipse, WebDriver(selenium standalone jar file), browser, application to be tested.

71. What method is used to get the title of the page?

By using getTitle() method, we can get the title of the page.

Syntax: driver.getTitle();

72. What is the method used to get selected option from dropdown list?

getOptions() is used to get the selected option from the dropdown list.

73. What is the method used to deselect all the selected options from the dropdown list?

deSelectAll( ) is the method used to deselect all the selected options from the dropdown list.

74. Is WebDriver is an interface or a class?

WebDriver is an Interface.

75. List out different types of Drivers available in WebDriver?

The different drivers available in WebDriver are:

  • FirefoxDriver
  • ChromeDriver
  • InternetExplorerDriver
  • SafariDriver
  • OperaDriver
  • AndroidDriver
  • IPhoneDriver
  • HtmlUnitDriver

76. Can Selenium handle windows based pop up?

The Windows-based popup cannot be handled by selenium because it supports only web applications.

77. What is the difference between getWindowhandle() and getwindowhandles()?

getwindowhandle() is used to get the address of the current browser, whereas

getwindowhandles() is used to get the address of all the open browsers.

78. What is the method used to switch back from a frame?

By using defaultContent() method, we can switch back from a frame.

driver.switchTo().defaultContent();

79. How do we submit a form using Selenium?

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

element.submit();

80. How do we maximize window using selenium?

driver.manage().window().maximize();

81. Can Mobile applications tested by WebDriver?

WebDriver cannot test Mobile applications.

82. How can we handle Multiple Browsers?

We can handle multiple browsers by using Browser window handle.

83. How to count the total number of rows of a table using Selenium 2.0?

List <WebElement> totrows = driver.findElements(By.tagname(“tr”));

int totalRow = totrows.size();

84. How can you perform double click in Webdriver ? (Important Selenium Interview Questions)

You can perform double click by using

Actions act = new Actions (driver);
act.doubleClick(webelement);

85. How can you handle colors in Selenium WebDriver?

We will use getCssValue(arg0) function to get the value of colors

86. How do you remove a selection from list box by using visible text?

By using deselectByVisibleText() method we can remove selection from list box.

Select listbox = new Select(driver.findElement(By.xpath(“//select[@name=’ListBox’]”)));

listbox.deselectByVisibleText(“India”);

87. What are the different types of navigation commands? (Important Selenium Interview Questions)

navigate().back(): This command takes back the user to the previous web page on the web browser’s history.

Syntax: driver.navigate().back();

navigate().refresh(): This method Refresh the current web page.

Syntax: driver.navigate().refresh();

navigate().forward(): This command takes us forward by one page on the browser’s history.

Syntax: driver.navigate().forward();

navigate().to(): This command allows us to navigate on specific page or URL in between your test.

Syntax: driver.navigate().to(“https://yahoo.com”);

88. How do you remove a selection from list box by value?

By using deselectByValue() method we can remove selection from list box.

Select listbox = new Select(driver.findElement(By.xpath(“//select[@name=’ListBox’]”)));

listbox.deselectByValue(“India”);

89. What is the method used to switch from one window to another window of software web application?

WebDriver.switchTo().window() is the method used to switch from one window to another window of software web application.

90. How can we handle dynamic elements without using XPath? (Important Selenium Interview Questions)

By using classname or css selector we can handle dynamic elements without XPath.

91. How do you verify if the checkbox/radio button is checked or not?

We use the isSelected() method to verify if a checkbox or radio button is checked or not.

Syntax:

driver.findElement(By.xpath(“xpath of checkbox/radio button”)).isSelected();

Save

Save

About the author

Vaibhav Singhal author

Vaibhav is in software testing since a decade. Worked with different testing techniques along with exploratory testing. Performed different regression, performance, api etc testing with tools and libraries like selenium, jmeter, loadrunner, protractor, rest assured, Katalon Appium and others.

Leave a Reply

Your email address will not be published.