Selenium WebDriver Interview Questions
In this section, we will be sharing the most commonly Selenium WebDriver Interview Questions for Selenium WebDriver. You are going to any year’s experience profile, revise questions. For more Interview questions, You Can Visit Our SoftwareTestingo Regularly.
The difference between absolute path & Relative path
Absolute path starts from “HTML” example “html/body/div/div/div/” Relative path is in reference to example “By.xpath(“//table[@id=’name’]”
Scenario: There is a building let’s generate its path:
Tell me some TestNG Annotations
What are the Desired capabilities
Desired Capability is a series of key/value pairs that encapsulate aspects of a browser means we can set the behavior of the browser on the runtime. The Desired Capabilities help to set properties for the WebDriver. A typical use case will be to set the path for the FireFoxDriver if our local installation doesn’t correspond to the default settings.
The difference between Selenium RC and Selenium Web driver
- Selenium RC is an old version of Selenium Web Driver
- In Selenium RC, we need to start the server, it acts as communication between Selenium RC and browser. The server injects code into the browser and executes automation.
- In the case of WebDriver, it communicates directly with Selenium RC
- Also simple language we can selenium Webdriver supported for Java Object Orient Programming.
What is Automation Framework
The framework is a process that will make automation develop and maintain a team. The framework includes what would be folder structure, Common function library, how would be storing and fetching test data, how would be storing the result, how continuous integration will be performed, etc
What is the difference between a driver.Close() and driver.Quit () method?
- Driver.close(): will close the browser which is in focus of web driver object
- Driver.quit(): will close all the browsers and closes the session
How can we get the font size, font color, font type used for a particular text on a web page using Selenium web driver
- System.out.println(“WebElement Font Size is : “+ driver.findElement(By.id(“submitbox”)).getCssValue(“font-size”));
- System.out.println(“WebElement Font Color is : “+driver.findElement(By.id(“submitbox”)).getCssValue(“font-color”));
- System.out.println(“WebElement Font Background Color is : “+driver.findElement(By.id(“submitbox”)).getCssValue(“background-color”));
How to Run Tests in Multiple Browser Parallel
Selenium-Grid allows you to run your tests on different machines against different browsers in parallel
What is Selenium 2.0
- Selenium 1.0: Selenium RC
- Selenium 2.0: Selenium WebDriver
How will you find an element using Selenium
- By ClassName
- By CssSelector
- By ID
- By LinkText
- By Name
- By TagName
- By XPath
Mention what is the use of X-path
We can interact with the Website with properties ID, CLASSNAME, NAME, etc. XPath is another way to navigate through elements and attributes in an XML document. As per W3C:
- XPath is a syntax for defining parts of an XML document
- XPath uses path expressions to navigate in XML documents
- XPath contains a library of standard functions
- XPath is a major element in XSLT
- XPath is a W3C recommendation
Technical Challenges with Selenium
- Selenium supports only web-based applications
- It doesn’t support any non-web based (Java Applet, Java Swing, .Net Client Server, etc.) applications
- Since Selenium is a free tool, there is no direct support available
- Bitmap comparison not supported by Selenium
- No direct reporting, logging, test data handling feature available
- Need to learn a language for scripting with selenium
- Sometimes pages take more time to load when working with Selenium.
- For uploading and downloading file no separate feature present, sometimes need to take help of window automation tools like AutoIT.
- No built-in repository available, have to use .properties file or other feature to create object repository
What are the Advantages of Selenium
- Supports multiple browsers
- Provides the option of using the full range of IDEs such as Eclipse, Netbeans, etc
- Supports multiple languages JAVA, NET, Ruby, etc
- Extensive Selenium community
- Selenium is open-source. Most open-source tools help other open-source tools
- Selenium supports Continuous Integration
- Various options to find an element on a website
- Same developed scripts run on multiple browsers
Mention what the Difference between Implicit wait and Explicit wait is?
We tell the web driver to wait for specific time suppose 10seconds before any web element Implicit wait: be visible on the website. The implicit wait is applied to all elements present after declaring once.
- Implicit wait: is applied to all elements present after declaring once. If an element is visible in 2 seconds, that web driver won’t wait for the next 8 seconds.
- Explicit wait: wait is applied for a specific element, not all elements. In Explicit wait, we tell the web driver to wait for this particular element until any condition is fulfilled. For example, wait for the submit button for 10 seconds until the element becomes clickable.
Explain what is the Difference between find element() and find elements()
- findElement() will return only single WebElement, and if that element is not located or we use some wrong selector, then it will throw NoSuchElement exception. If multiple elements are present with the same selector, then it will give the first element.
- findElements() will return List of WebElements – for this, we need to provide a locator in such a way that it can find multiple elements
Explain what is Data-driven framework and Keyword driven
- Data-driven framework: In this test are created, verified, and executed based on test data stored in some database, either Excel, SQL, etc. In the simplest form, the tester supplies the inputs from a row in the table and expects the outputs which occur in the same row.
- Keyword-driven framework: Also known as table-driven testing or action word based testing. This method separates the documentation of test cases -including the data to use- from the prescription of the way the test cases are executed. As a result, it separates the test creation process into two distinct stages: a design and development stage, and an execution stage.
What is Object Repository
Object Repository is the location where we can store information/properties of our elements, and scripts identify the features from Object Repository to identify them.
How do you verify if the Checkbox/Radio is checked or not
How do you launch IE/chrome browser
You need to download the executable file for chrome/IE and run commands
System.setProperty(“webdriver.chrome.driver”, “path to executable file”); WebDriver driver = new ChromeDriver();
How do you upload a file
We can use the Selenium “sendKeys” function if it didn’t work then we need to use the help of Windows Automation Tools like Auto IT
How do you get the current page URL
How to get a typed text from a textbox
What are the prerequisites to run selenium web driver
Knowledge of Java and any other supported Programming language
What is Selenium Grid
Selenium Grid allows you to run your tests on different machines against different browsers in parallel. That is, running multiple tests at the same time against different machines running different browsers and operating systems
How to get the title of the page
FirefoxDriver is a class or an interface
How do you handle https website in selenium
FirefoxProfile myProfile = allProfiles.getProfile(“CertificateIssue”); myProfile.setAcceptUntrustedCertificates(true);
HTML unit driver is the lightest weight and fastest implementation headless browser for WebDriver
What are the benefits of using TestNG
- It generates logs.
- You can do parallel testing.
- Annotations help to set program/function priority easy.
- Allow generating an HTML report of execution.
- You can group test cases.
- You can set test case priorities.
- You can do data Parameterization.
What is the use of AutoIt tool
AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.
How to perform double click using WebDriver
Actions action = new Actions(driver); WebElement element = driver.FindElement(By.id(“submit”)); action.DoubleClick(element).Build().Perform();
What is the difference b/w getWindowHandles() and getWindowHandle()
- getWindowHandles()- is used to get the address of all the open browser, and its return type is Iterator<String>.
- getWindowHandle()- is used to get the address of the current browser where the control is, and return type is String.
What are the limitations of Selenium IDE
Selenium IDE is a record, and play tool can only support Mozilla browser
How will you handle dynamic elements
We use Relative XPath
Which one is better XPath or CSS
CSS Locator has better performance than the XPath Locator
What is the actions class in WebDriver
The user-facing API for emulating complex user gestures. Use this class rather than using the Keyboard or Mouse directly.
Most Searched Words: Selenium WebDriver Interview Questions for Freshers, WebDriver Interview Questions For Experience, Top WebDriver Interview Questions, Highly asked WebDriver Interview Questions, common WebDriver Interview Questions recently asked WebDriver Interview Questions