Self Learning Videos       Live Training Courses        +91 988 502 2027

Top 50 Selenium Testing Interview Questions And Answers Pdf

Top 50 Selenium Testing Interview Questions And Answers Pdf

1. How do I launch the browser using WebDriver ? (Top 50 Selenium Testing Interview Questions And Answers Pdf)

Answer: The following syntax can be used to launch Browser:
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();

Top 50 Selenium Testing Interview Questions And Answers Pdf

2. What is the difference between POI and jxl jar ?

JXL supports “.xls” format i.e. binary based format. JXL doesn’t support Excel 2007 and “.xlsx” format i.e. XML based format
JXL API was last updated in the year 2009
The JXL documentation is not as comprehensive as that of POI
JXL API doesn’t support rich text formatting
JXL API is faster than POI API

POI jar supports all of these formats
POI is regularly updated and released
POI has a well prepared and highly comprehensive documentation
POI API supports rich text formatting
POI API is slower than JXL API

3. How to assert title of the web page ?

Answer: //verify the title of the web page
assertTrue(“The title of the window is incorrect.”,driver.getTitle().equals(“Title of the page”));

4. What is a data-driven framework ?

Answer: The Data Driven test design framework follows a design paradigm where test logic is fixed but varies the test data. The data itself can be in different repositories like a simple .csv file, .json file or .xls sheet, or database and can add the tests merely updating those external files or DB (instead of placing in test code itself).

5. What is Object Repository? How can we create Object Repository in Selenium ?

Answer: Object Repository is a term used to refer to the collection of web elements belonging to Application Under Test (AUT) along with their locator values. Thus, whenever the element is required within the script, the locator value can be populated from the Object Repository. Object Repository is used to store locators in a centralized location instead of hard coding them within the scripts.
In Selenium, objects can be stored in an excel sheet which can be populated inside the script whenever required.
That’s all for now.
Hope in this article you will find answers to most frequently asked Selenium and WebDriver Interview questions. The answers provided here are also helpful for understanding the Selenium basics and advanced WebDriver topics.
Do you have any Selenium Interview questions that are not answered here? Please let us know in comments below and we will try to answer all.

6. How a text written in a text field could be cleared ?

Answer: A text written in a text field could be deleted by using the clear() method.

7.Can WebDriver test Mobile applications ?

Answer: WebDriver cannot test Mobile applications. WebDriver is a web based testing tool, therefore applications on the mobile browsers can be tested. (SVR Technologies)

8. What is the FirefoxDriver, class or an interface? And which interface does it implement?

Answer: FirefoxDriver is a Java class. It implements all the methods available in the interface.

9. Explain how you can capture server side log Selenium Server ?

Answer: To capture server side log in Selenium Server, you can use command: java –jar .jar –log selenium.log

10. How to verify if the checkbox/radio is checked or not ?

Answer: is Selected() method is used to verify if the checkbox/radio is checked or not.

Top 44 Tomcat Interview Questions And Answers Pdf

11. What is the difference between findElement () and findElements () ?

Answer: Both of them let user to find elements in the current web page matching to the specified locator value. But if you use find Element(), only the first matching element would be fetched.(Salesforce Certification Training Online)

12. Can we use Selenium RC for tests driving on two different browsers on one operating system without Selenium Grid ?

Answer: We can do it if JAVA testing framework is not used. If we use Java client driver of Selenium, instead of using Java testing framework, TestNG allows us not to use Selenium Grid.

13. What is IntelliJ ?

Answer: IntelliJ is an IDE that helps users to write code for Selenium better and faster. It could be used as an option to Java bean and Eclipse.

14. How can I read test data from excels ?

Answer:Test data can efficiently be read from excel using JXL or POI API. See detailed tutorial here.

15. How can we handle Web-based pop-up ?

Answer:There are four methods of the effective Web-based pop-up handling:
string getText() method returns the text displayed on the alert box
void accept() method clicks on the “Ok” button as soon as the pop-up window appears
void dismiss() method clicks on the “Cancel” button as soon as the pop-up window appears
void sendKeys(String stringToSend) method enters the specified string pattern into the alert box. (Top 50 Selenium Webdriver Interview Questions And Answers Pdf)

16. Which webdriver implementation is the fastest ?

Answer:The fastest Web Driver is Html Unit Driver. Differing of other drivers (Fire Fox Driver, Chrome Driver etc), it’s non-GUI, while running no browser gets launched.

17. How would you test your own element locator ?

Answer: “Find Button” of Selenium IDE is used to test the locator. Clicking on this button, you will see on screen if your element locator is right or wrong.
Also, you can use “FirePath” plugin in FireFox.(Company)

18. How to set test case priority in TestNG ?

Answer: TestNG “Priority” is used to schedule the test cases. In order to achieve, we need to add an annotation as @Test(priority=??). The default value will be zero for priority. If you don’t mention the priority, it will take all the test cases as “priority=0” and execute.
The example below shows the usage of the priority for test cases.
As we have not defined the priority for test case “Registration”, it will get executed first and then the other test cases based on priority.

19. How do you send ENTER/TAB keys in WebDriver ?

Answer: use click() or submit() methods are used for ENTER. But, don’t forget that submit() method is used only if type=’submit’.
You can use Actions class act.sendKeys(Keys.ENTER) for TAB.

20. How could AJAX controls be handled in WebDriver ?

AJAX allows the Web page to retrieve small amounts of data from the server without reloading the entire page.
The different wait methods should be applied for testing Ajax application:
Thread Sleep
Implicit Wait
Explicit Wait
Fluent Wait

21. Could you explain the line of code Webdriver driver = new FirefoxDriver()?

‘WebDriver’ is an interface and we are creating an object of type WebDriver instantiating an object of FirefoxDriver class.

22. What is the alternate way to click on login button ?

submit() method could be used as the alternate way to click on login button, but only if attribute type=submit.

23.What is the testng.xml file used for ?

testng.xml file is used to configure the whole a test suite. Here we can create a test suite, create test groups, mark tests for parallel execution, add listeners and pass parameters to test scripts. It can be used for the further test suite triggering.(Selenium Online Training)

24. How many exemptions do you know in Selenium WebDriver ?

There are 5 different exceptions Selenium WebDriver:

25. Do you know a way to refresh browser by using Selenium ?

The list of commands to refresh a page in Selenium:

26. Do you know a way to refresh browser by using Selenium ?

The list of commands to refresh a page in Selenium:

27. How will you use Selenium to upload a file ?


File uploading action could be performed by using element.sendKeys(“path of file”) on the webElement of input tag and type file: < name=”fileUpload” type=”file” />

28. What methods of Robot Class do you know ?


Some commonly and popularly used methods of Robot Class during web automation

29. What is the purpose of deSelectAll() method ?


It is used to deselect all the options which have been selected from the drop-down list.

30.What is the difference between @Factory and @Data Provider annotation ?


@DataProvider is concerned to individual test methods and run the specific methods for many times. @Factory method creates test class instances and runs all the test methods in that class with different data. sets.

31. What is the purpose of getOptions() method ?


getOptions() is used to get the selected option from the drop-down list.

32. What is Robot API ?


Robot API is used to control keyboard or mouse to interact with OS windows like Download pop-up, Alerts, Print Pop-ups, etc. or native Operating System applications like Notepad, Skype, Calculator, etc.

33. How to login into any site if it’s showing any authentication pop-up for
username and password?


You should pass the username and password with URL:

34. When AutoIT is used ?


Auto IT is used to handle window GUI and non-HTML popups in the application.

35. Explain why to choose Python over Java in Selenium ?


Here are some points that favor Python over Java to use with Selenium:
Python is simpler and more compact compared to Java
Java uses traditional braces to start and ends blocks, while Python uses indentation
Java employs static typing, while Python is dynamically typed
Java programs tend to run slower compared to Python programs

36. How can you handle network latency using Selenium ?


You can use driver.manage().timeouts().pageLoadTimeout(); for network latency.

Top 50 Selenium Testing Interview Questions And Answers Pdf

37. What is the difference between driver.close() and driver.quit command ?


Object repository is an essential entity in any UI automation which allows a tester to store all object that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

38. What are the main advantages of Selenium ?


Selenium is a free and open source. You don’t need to spend any licensing cost to use it.
Cross Browser compatibility (Firefox, Chrome, Internet Explorer, Safari etc.)
Multiple programming languages (Java, C#, Ruby, Python, Pearl etc.) support
Compatibility with the main platform (Windows, Mac OS, Linux etc.)

39. How can we find the value of different attributes like name, class, value of an element?


Using getAttribute(“{attributeName}”) method we can find the value of different attrbutes of an element e.g.-
String valueAttribute =

40. How to delete cookies in selenium ?


Using deleteAllCookies() method-

41. What is an implicit wait in selenium ?


An implicit wait is a type of wait which waits for a specified time while locating an element before throwing NoSuchElementException. As by default selenium tries to find elements immediately when required without any wait. So, it is good to use implicit wait. This wait is applied to all the elements of the current driver instance.

42. What is an explicit wait in selenium ?


An explicit wait is a type of wait which is applied to a particular web element untill the expected condition specified is met.

WebDriverWait wait = new WebDriverWait(driver, 10);

WebElement element = wait.until(ExpectedConditions.elementToBeClickable(“elementId”)));

43. What are some expected conditions that can be used in Explicit waits ?

Some of the commonly used expected conditions of an element that can be used with expicit waits are-
elementToBeClickable(WebElement element or By locator)
stalenessOf(WebElement element)
visibilityOf(WebElement element)
visibilityOfElementLocated(By locator)
invisibilityOfElementLocated(By locator)
attributeContains(WebElement element, String attribute, String value)
titleContains(String title)
titleIs(String title)
textToBePresentInElementLocated(By, String)

44. What is fluent wait in selenium ?

A fluent wait is a type of wait in which we can also specify polling interval(intervals after which driver will try to find the element) along with the maximum timeout value.
Wait wait = new FluentWait(driver)
.withTimeout(20, SECONDS)
.pollingEvery(5, SECONDS)
WebElement textBox = wait.until(new Function() {
public WebElement apply(WebDriver driver) {
return driver.findElement(“textBoxId”));

45. How to mouse hover an element in selenium ?

Code to mouse hover over an element in selenium-
Actions action = new Actions(driver);
Web Element element=driver. find Element(“element Id”));
action. move To Element(element).perform();

46.What are DesiredCapabilities in selenium webdriver ?

Desired capabilities are a set of key-value pairs that are used for storing or configuring browser specific properties like its version, platform etc in the browser instances.

47.What are some commonly encountered exceptions in selenium ?

Some of the commonly seen exception in selenium are-
NoSuchElementException – When no element could be located from the locator provided.
ElementNotVisibleException – When element is present in the dom but is not visible.
NoAlertPresentException – When we try to switch to an alert but the targetted alert is not present.
NoSuchFrameException – When we try to switch to a frame but the targetted frame is not present.
NoSuchWindowException – When we try to switch to a window but the targetted window is not present.
UnexpectedAlertPresentException – When an unexpected alert blocks normal interaction of the driver.
TimeoutException – When a command execution gets timeout.
InvalidElementStateException – When the state of an element is not appropriate for the desired action.
NoSuchAttributeException – When we are trying to fetch an attribute’s value but the attribute is not correct
WebDriverException – When there is some issue with driver instance preventing it from getting launched.

48. How to check which option in the dropdown is selected ?

Using isSelected() method we can check the state of a dropdown’s option.
Select countriesDropDown = new Select(driver.findElement(“countries”)));
//returns true or false value

49. How to locate a link using its text in selenium ?

Using linkText() and partialLinkText() we can locate a link. The difference between the two is linkText matches the complete string passed as parameter to the link texts. Whereas partialLinkText matches the string parameter partially with the link texts.
WebElement link1 = driver.findElement(By.linkText(“artOfTesting”));
WebElement link2 = driver.findElement(By.partialLinkText(“artOf”));

50. How can we capture screenshots in selenium ?


Using getScreenshotAs method of TakesScreenshot interface we can take the screenshots in selenium.
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(“D:\\testScreenShot.jpg”));

Boost your career skills
Faculty: 10+ Years Experience   ---   Duration: 30 - 35 Hours
​100% Hands on Classes   ---   Real Time Scenarios   ---   Free Recordings
Make an Enquiry ! ask your queries.