1. Do you know the difference between close and quit command?
If you need to close the current browser having focus driver.close() is used. If you need to close all the browser instances driver.quit() is used.
2. Do you know what is a data-driven framework?
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).
3. Tell me the fundamental difference between XPath and CSS selector?
Using CSS selector we can only move downwards in the document, using XPaths we traverse up in the document.
4. Tell us how can you create HTML test report from your test script?
There are three ways of HTML test report creation:
☛ using inbuilt default.html to get the HTML report in TestNG
☛ with the ANT help in JUnit
☛ using XSL jar for converting XML content to HTML in own customized reports
5. Tell us how can you run Selenium Server other than the default port 4444?
Selenium server could be run on java-jar selenium-server.jar-port other than its default port.
6. Tell us what is JUnit? And what is JUnit Annotation?
JUnit is an open source Java applications testing framework, introduced by Apache. A process of adding a special form of syntactic metadata to Java source code is called annotation. JUnit Annotations are: variables, parameters, packages, methods and classes.
7. Explain me what could be the cause of Selenium WebDriver test to fail?
There are some causes of Selenium WebDriver test to fail:
☛ SeleniumWebDriver element waiting to access did not appear on the web page and the operation timed out
☛ SeleniumWebDriver is trying to access not created element
☛ SeleniumWebDriver cannot locate the element, because the locator has been changed
8. Do you know what is a XPath?
XPath is a language that describes a way to locate and process items in Extensible Markup Language (XML) documents by using an addressing syntax based on a path through the document's logical structure or hierarchy.
9. Tell me do you know a way to refresh browser by using Selenium?
The list of commands to refresh a page in Selenium:
☛ navigate().refresh()
☛ getCurrentUrl()
☛ navigate().to(driver.getCurrentUrl())
☛ sendKeys(Keys.F5)
10. Tell us 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" />
11. Tell us can we find all links on a web page?
As all links are of anchor tag 'a', so we can find all of them on a web page by locating elements of tagName ‘a':
List links = driver.findElements(By.tagName("a"));
12. Tell me how colors could be handled in Selenium WebDriver?
To handle colors could be handled in Selenium WebDriver by using Use getCssValue(arg0) function to get the colors by sending ‘color' string as an argument.
13. Tell us the difference between assert and verify commands?
Both of them check if the given condition is true or false. Unlike to "assert", "verify" will not stop the test case execution if the test case fail.
14. Tell me how can we launch different browsers in Selenium WebDriver?
We should create an instance of a driver of a particular browser:
WebDriver driver = new FirefoxDriver();
15. Tell us how could you explain the main difference between WebDriver and RC?
Selenium WebDriver drives the browser using built-in support. RC injects JavaScript function into browsers when the page is loaded.
16. Explain me which web driver implementation is the fastest?
The fastest WebDriver is HtmlUnitDriver. Differing of other drivers (FireFoxDriver, ChromeDriver etc), it's non-GUI, while running no browser gets launched.
17. Tell me how do perform drag and drop using Selenium WebDriver?
The next Actions class is used to perform drag and drop:
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(SourceElement)
moveToElement(TargetElement)
release(TargetElement)
build();
dragAndDrop.perform();
18. Tell me how can the user get a text of a web element?
User can retrieve the text of the specified web element by using get command. It doesn't require any parameter but returns a string value.
String Text = driver.findElement(By.id(“Some Text”)).getText()
is an example of it.
19. Tell me the meaning of assertion in Selenium and what are the types of assertion?
Assertion is used as a verification point. It verifies that the application state conforms to the expectation. The types of assertion are “assert”, “verify” and “waifFor”.
20. Tell me 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:
☛ ThreadSleep
☛ Implicit Wait
☛ Explicit Wait
☛ WebdriverWait
☛ Fluent Wait
21. Tell me what is a keyword-driven framework?
The keyword driven framework is a methodology where actions or steps are treated as keywords. These keywords (like click, move, type etc.,) are stored in some external repositories along just like data (in .csv/.json/.xls/DB).
22. Explain me how to check if an element is visible on the page?
The return method type is logical. If it returns true then element is visible otherwise it is not. isDisplayed() method could be used for it:
driver.findElement(By.id(“id_of_element”)).isDisplayed();
23. Do you know how to verify if the checkbox/radio is checked or not?
isSelected() method is used to verify if the checkbox/radio is checked or not. An example -
driver.findElement(By.xpath("XPath of the checkbox/radio button")).isSelected();
24. Do you know how to mouse hover an element in Selenium?
Code to mouse hover over an element in Selenium:
Actions action = new Actions(driver);
WebElement element=driver.findElement(By.id("elementId"));
action.moveToElement(element).perform();
25. Tell us how do you get the width of the textbox?
You can get the width of the textbox by using the following command:
driver.findElement(By.xpath(“xpath of textbox ”)).getSize().getWidth();
driver.findElement(By.xpath(“xpath of textbox ”)).getSize().getHeight()
26. Please explain what is the hybrid framework?
The combination of data driven and keyword driven framework is called the hybrid. Here the operations/instructions/keywords in a separate repository (.csv/.xls/.json/DB) and data is in separate (.csv/.xls/.json/db from data provider) and the tests/driver would read both and perform the actual tests automatically. In this design, we get the best of both methodologies, and it is kind of practical in most of the automation cases.
27. Tell me how would you test your own element locator?
“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
28. Explain me how can we capture screenshots in Selenium?
We can take the screenshots in selenium by using getScreenshotAs method of TakesScreenshot interface:
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("C:screenshot1.jpg"));
29. Please explain what is the difference between findElement () and findElements ()?
Both of them let user to find elements in the current web page matching to the specified locator value. But if you use findElement(), only the first matching element would be fetched. An example:
WebElement element = driver.findElements(By.xpath(“//div[@id='example']//ul//li”))
If you use findElements(), the all matching elements would be fetched and stored in the WebElements list. An example:
List elementList = driver.findElements(By.xpath(“//div[@id='example']//ul//li”));
30. Tell us what Selenium components do you know?
Selenium is a suite of tools for automated web testing. It is composed of:
☛ Selenium IDE (Integrated Development Environment). It is a tool for recording and playing back. It is a Firefox plugin.
☛ WebDriver and RC. It provides the APIs for a variety of languages like Java, .NET, PHP, etc. They work with most of the browsers.
☛ Grid: you can distribute tests on multiple machines so that test can be run parallel which helps cutting down the time required for running test suites in the browser.
31. Tell us how can you find if an element is displayed on the screen?
There are different methods, which help user to check the visibility of the web elements:
☛ isDisplayed(),
☛ isEnabled(),
☛ isSelected().
These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.
32. Tell me what kind of mouse actions can be performed in Selenium?
Selenium supports different mouse actions, such as:
☛ click(WebElement element)
☛ contextClick(WebElement element)
☛ doubleClick(WebElement element)
☛ mouseUp(WebElement element)
☛ mouseDown(WebElement element)
☛ mouseMove(WebElement element)
☛ mouseMove(WebElement element, long xOffset, long yOffset)
33. Tell us what is the difference between getWindowHandles() and getWindowHandle()?
You can get the browser address using these commands. But if you use getWindowHandle(), you'll get the address of the current browser where the control is and return type is a string. So, if you use getWindowHandles(), you will get the address of all the open browser and its return type is an iterator.
34. Do you know how can we make one test method dependent on other using TestNG?
We can make one test method run only after successful execution of dependent test method by using dependsOnMethods parameter inside @Test annotation in TestNG: @Test(dependsOnMethods = { "preTests" })
35. Explain me what is a framework and what are the frameworks available in RC?
The framework is a collection of libraries and classes for helping testers to automate test cases. NUnit, JUnit, TestNG, Bromine, RSpec, unit tests are some of the frameworks available in RC.