Top 100 Selenium Interview Questions and Answers

Selenium refers to an open-source automation testing tool utilized to automate web browsers via distinct platforms. These top 100 interview questions & answers about Selenium cover different topics that are linked to Selenium. The topics include its components, programming languages supported, locators, advantages, XPath, WebDriver, CSS selector, WebElement, TestNG, Page Object, Maven, Jenkins, etc. These questions will assist you when preparing for a Selenium interview & assess your knowledge plus skills when utilizing Selenium in web automation testing.

Basic Selenium Interview Questions

1. What is Selenium & what is it composed of?

Selenium refers to an open-source automation testing tool that’s utilized in automating web browsers across various platforms. It enables testers & developers to compose test scripts in different programming languages including Java, C#, Python, Ruby, & JavaScript in automating the testing of web apps. Selenium comes with four components:

  1. Selenium IDE: It’s a record & playback tool utilized in creating test cases quickly minus any programming knowledge.
  2. Selenium Remote Control (RC): It’s the first version of Selenium that enables users to write test scripts in several programming languages.
  3. Selenium WebDriver: It’s the successor of Selenium Remote Control, and it enables users to interact with some web pages utilizing different programming languages.
  4. Selenium Grid: It’s utilized to distribute test cases across numerous machines, browsers, and operating systems, concurrently decreasing the period needed to run test cases.

2. What’s Selenium 2.0?

Selenium 2.0 refers to a major release of the Selenium automation testing tool which was released back in 2011. It’s comprised of significant changes plus improvements to the Selenium toolset, including the introduction of WebDriver API, which substitutes the earlier Selenium Remote Control API.

Moreover, Selenium 2.0 also introduced an extra modular architecture which makes it simpler to develop plus maintain Selenium-based automation testing frameworks. Furthermore, it also provides improved support for numerous programming languages like Java, C#, Python, Ruby, & JavaScript, and provides better integration with common development tools plus frameworks like TestNG, Jenkins, and Maven.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Example {

  public static void main(String[] args) {
    WebDriver driver = new FirefoxDriver();
    driver.get("https://www.google.com");
    driver.findElement(By.name("q")).sendKeys("Selenium");
    driver.findElement(By.name("btnK")).click();
  }
}

3. Mention what’s Selenium 3.0?

This is the latest version of the Selenium automation testing tool, which was first released back in 2016. This tool builds upon some features & improvements introduced in Selenium 2.0 & includes more new features & enhancements.

Among the most significant changes in Selenium 3.0 is the deprecation of a Selenium RC API. Instead, this recommends utilizing the WebDriver API, that’s now completely supported across every major browser. In addition, Selenium 3.0 also contains improvements to WebDriver API, like the ability to interact together with HTML5 elements, file uploads, and native alerts.

Selenium 3.0 also offers better support for browser compatibility testing, like new browser drivers for Safari and Microsoft Edge. Additionally, it also includes better support for mobile testing via the Appium framework that enables the automation of mobile apps using Selenium.


4. How will one get an element using Selenium?

How will one get an element using Selenium?

Selenium offers various ways of locating elements on a web page. Here are some of the most commonly utilized ways to find elements utilizing Selenium:

  • By ID: The ID attribute is distinct for every element on a web page. One could utilize the findElement(By.id()) method to get an element using its ID.
  • By Name: The name attribute is also distinct for every element on the web page. You can utilize the findElement(By.name()) method in finding an element by its Name.
  • By Class Name: The class Name attribute is shared by numerous elements on a web page. You can utilize the findElement(By.className()) method in finding an element by its Class Name.
  • By Tag Name: The tag Name attribute is shared by numerous elements on a web page. You can utilize the findElement(By.tagName()) method to find an element using its Tag Name.
  • By Link Text: One could utilize the findElement(By.linkText()) method to find an element by the link text which appears on a web page.
  • By Partial Link Text: One could utilize the findElement(By.partialLinkText()) method to find an element using a partial match of a link text which appears on a web page.
  • By CSS Selector: You can utilize the findElement(By.cssSelector()) method to get an element utilizing CSS selectors.
  • By XPath: You can utilize the findElement(By.xpath()) method to get an element utilizing XPath expressions.

Note that every method highlighted above returns a single element. When you need to locate multiple elements, you can utilize the corresponding findElements() method instead.


5. List the test types which are supported by Selenium?

Selenium is majorly utilized for web application testing, & it supports numerous kinds of tests, including:

  • Regression Testing: This testing ensures that every change made to an app doesn’t affect its existing functionality. This involves testing an application repeatedly to confirm that it continues to operate correctly after every change.
  • Cross-Browser Testing: This testing checks the compatibility of an application across various browsers & their versions.
  • Functional Testing: Functional testing confirms if an application’s functionality operates as expected. It includes testing the application’s user interface, links, buttons, forms, plus other user interactions.
  • Load Testing: This checks the performance of an application on a heavy load of users. The testing involves testing the application’s response time, overall performance, and resource usage.
  • Integration Testing: This testing checks the integration of various modules of an application to guarantee that they operate correctly together.
  • Smoke Testing: This is a quick test that guarantees that the application’s critical functionalities operate correctly before continuing with further testing.
  • Acceptance Testing: Acceptance testing includes testing the application’s functionality & performance to guarantee that it satisfies the end-users requirements.

6. Explain what’s an assertion in Selenium & what are the varieties of assertions.

In Selenium, we use assertions in validating if a given condition is false or true in an application that’s tested. Assertions are important in automated testing since they assist in ensuring that the application is working as expected and that we have no unexpected errors.

The varieties of assertions include “assert”, “verify” & “waitFor”.


7. Mention what’s the use of an X-path.

XPath refers to a language utilized for locating elements on a web page. It offers a means of navigating & selecting elements depending on their properties and attributes. XPath is used in Selenium to find elements utilizing expressions that define the element’s path in the HTML document.

Below are some benefits of utilizing XPath in Selenium:

  • XPath enables one to find elements utilizing complex & nested hierarchies.
  • XPath can find elements depending on their attributes such as type, id, class, name, etc.
  • XPath offers a means of locating elements depending on their text content or their child elements content.
  • XPath expressions are utilized to find elements depending on their position in a document like the first or last element on a certain type.
  • XPath works with modern browsers and can be utilized with Selenium in automating the testing of web apps.
  • XPath expressions are composed utilizing a syntax same to that of file paths in operating systems. The expression begins with a forward slash (/) and includes elements, functions, and attributes. XPath is utilized with both XML and HTML documents.

8. Explain the difference between single & double slash in X-path.

In XPath, forward slash (/) & double forward slash (//) have distinct meanings and they are utilized for various purposes.

Single forward slash (/) is utilized to choose the direct child element, while double forward slash (//) is utilized to choose all the matching child elements, irrespective of their position in the hierarchy. Single slash enables one to create ‘absolute’ path expressions while double Slash ‘// allows one to create ‘relative’ path expressions.


9. List out technical issues associated with Selenium

Below are some of the technical challenges that are encountered while utilizing Selenium:

  • Synchronization: This is an important aspect of automated testing using Selenium, as it guarantees that the test script waits for the application to fully load before relating with it. Moreover, synchronization can be challenging particularly when an application is unresponsive or slow.
  • Browser Compatibility: Selenium operates with various web browsers, but every browser has its own quirks & problems which could interfere with the testing process. To overcome this issue, testers need to test their application on various browsers & versions to guarantee cross-browser compatibility.
  • Handling Dynamic Web Elements: Dynamic web elements like pop-ups, dynamic menus, and AJAX calls can be challenging to deal with Selenium since their behavior is unpredictable. Testers must utilize advanced techniques like explicit waits and wait to handle these elements efficiently.
  • Test Maintenance: As the app evolves over time, test scripts made with Selenium need to be updated to imitate the changes. This can be challenging, particularly when there are numerous updates or changes to the application’s functionality.
  • Element Identification: Selenium depends on distinct identifiers to find elements on a web page like the id, class, name, etc. However, if a web page’s structure varies, these identifiers may not be dependable which makes it difficult to find elements. In such cases, testers need to utilize alternative methods like the CSS Selectors and Xpath to find the elements.
  • Reporting: Selenium doesn’t offer an in-built reporting capability, which makes it hard to generate a comprehensive test report. Moreover, testers must utilize third-party tools or plugins to create reports & track test outcomes effectively.

10. What’s the difference between type keys & type commands?

TypeKeys() triggers JavaScript events in several cases whereas .type() will not. Type key populates the value attribute utilizing JavaScript while .typekeys() imitates actual user typing. sendKeys() refers to a method offered by the WebDriver interface at Selenium & simulates the typing of keys at the keyboard. This command is utilized to enter text in an input element or a text field, one character at a time. Moreover, the sendKeys() method also enables one to send special keyboard keys like Enter, Tab, Shift, etc.


11. What’s the difference between verify & assert commands?

Difference between verify & assert commands
  • Verify: Verify command checks if the element is on a page, if it isn’t then the test will continue executing. In verification, every command is going to operate guaranteed even if a test fails. Verify command in Selenium is utilized in validating a condition, but it won’t stop the test execution if a condition isn’t met. This means that when verification fails, the test will keep on executing, and the outcomes will be noted as a failure.
  • Assert: Assert enables checking if an element is on the page or not. The test stops on the step failed if an asserted element isn’t available. In other words, the test will end at the point where the check fails. The assert command in Selenium is utilized to validate a condition & will instantly stop test execution if a condition isn’t met. This means that if an assertion fails, the remaining steps in a test case won’t be executed.

12. What are JUnit Annotations and what are various kinds of annotations that are useful?

JUnit is a more utilized unit testing framework for Java. JUnit offers a set of annotations that can be utilized to define the conduct of test methods & control the order of test execution. Among the significant JUnit annotations are:

  • @Before: This annotation is utilized to mark a method that should be executed before every test method. The method annotated using @Before is typically utilized to initialize test data & objects.
  • @AfterClass: This annotation is utilized to mark a method that should be executed once after every test method in the class is executed. The method annotated using @AfterClass is typically utilized to release resources that were initialized in a @BeforeClass method.
  • @Ignore: This annotation is utilized to mark a test method or test class which needs to be ignored during test execution. This test method or class annotated using @Ignore won’t be executed, and its outcome will be ignored.
  • @After: This annotation is utilized to mark a method that needs to be executed after every test method. The method annotated using @After is typically utilized to release resources & clean up after a test method.
  • @Test: This annotation is utilized to mark a method like a test method. This test method can be called numerous times all through test execution, and every time it should return minus throwing an exception to be considered as an effective test.
  • @BeforeClass: This annotation is utilized to mark a method that should be executed once before a test method in a class. The method annotated using @BeforeClass is typically utilized to set up configurations or common resources.

13. While utilizing the click command can you work with screen coordinate?

Yes, it is very possible to utilize screen coordinates together with the click command at Selenium. You can utilize the Actions class at Selenium to do click actions at a given location on the screen.

To click on a given section of an element, you will need to utilize the clickAT command. ClickAt command accepts element locator & x, y co-ordinates as arguments-

Remember that utilizing screen coordinates to do click actions isn’t recommended since it can be unreliable & the coordinates can differ depending on screen resolution & browser window size. It is better to utilize Selenium’s in-built locator strategies to find & interact with elements on a web page.


15. What are the Benefits of Selenium?

Selenium is a more used open-source test automation tool in web applications. Among the benefits of utilizing Selenium for test automation are:

  • Cross-browser compatibility: Selenium works with numerous web browsers such as Firefox, Chrome, Safari, and Internet Explorer which makes it simpler to test web apps across various browsers.
  • Multi-language support: Selenium works with multiple programming languages like Java, Python, Ruby, and C# enabling developers to select the language they are more comfortable with.
  • Open-source: Selenium is an open-source and free tool that makes it accessible to everyone & decreasing the general cost of test automation.
  • Huge community support: Selenium features a huge community of users & developers who contribute to its development, share their knowledge, and provide support, & best practices.
  • Integration with other tools: You can easily integrated selenium with other tools & frameworks like Jenkins, Cucumber, and TestNG enabling continuous integration & testing.
  • Record & playback feature: Selenium IDE offers a record & playback feature, which can be utilized to easily create test scripts minus writing any code.
  • Flexible & extensible: Selenium is an extensible and flexible tool that can be customized & extended to meet the particular needs of various projects.

 16. Why testers should go for Selenium & not QTP?

Both Selenium & QTP which are now known as UFT are common test automation tools & the choice between these two depends on the specific requirements and needs of the project. However, there are numerous reasons why testers prefer working with Selenium over QTP:

  1. Open-source: Selenium is a free and open-source tool, whereas QTP is a commercial tool. Thus Selenium is free to utilize which makes it more accessible & decreasing the general cost of test automation.
  2. Cross-platform support: Selenium works with numerous operating systems like Windows, Linux, and macOS, while QTP just supports Windows.
  3. Cross-browser compatibility: Selenium works with numerous web browsers like Chrome, Firefox, Internet Explorer, and Safari, while QTP just supports Internet Explorer.
  4. Multi-language support: Selenium works with numerous programming languages like Java, C#, Python, & Ruby, while QTP works with VBScript only.
  5. Integration with different tools: Selenium can be integrated easily with other tools & frameworks like Jenkins, Cucumber, and TestNG enabling continuous integration plus testing. QTP also offers integration with other tools although the options are limited.
  6. Flexibility & Customization: Selenium is an extensible and flexible tool that can be extended or customized to meet the specific requirement of various projects, while QTP features some limitations in terms of flexibility and customization.

17. What are the four parameters you’ve to pass in Selenium?

The four parameters which you have to pass at Selenium include

  • Host: The IP address or the hostname of a remote Selenium server to link to. This can be the IP address of a remote server or a virtual machine where the Selenium server is running.
  • Port Number: This is the port number utilized by the remote Selenium server for communication. 4444 is the automatic port number for the Selenium server, but you can customize it when needed.
  • Browser: The name of a web browser to utilize for testing. This can be a browser supported by Selenium like Chrome, Internet Explorer, Firefox, or Safari.
  • URL: The URL of a web page to test. This can be any URL as long as it’s valid and a web browser can go to, like the local file or a webpage on the internet.

18. What’s the difference between the setSpeed() & sleep() methods?

Both setSpeed() & sleep() methods are utilized in Selenium to introduce a pause or delay in test execution. Moreover, there’s a significant difference between these two methods:

  • setSpeed(): The setSpeed() method refers to a Selenium-specific method that’s utilized to slow down the execution of a test script. It requires a single argument that states the number of milliseconds that Selenium should pause in between every command. This method is majorly utilized for debugging purposes since it enables testers to see what’s happening in the web browser in slow motion. Moreover, it shouldn’t be utilized in production test scripts since it can significantly slow down a test execution time.
  • sleep(): The sleep () method is a general-purpose method that’s part of a Java programming language. It’s utilized to pause the execution of a test script for a given number of milliseconds. Unlike with the setSpeed(), sleep() isn’t Selenium-specific and could be utilized in any Java program. However, just like setSpeed(), it needs to be utilized judiciously in test scripts, since it can slow down the test execution time & make the tests to be less efficient.

Both will slow the execution speed

  • It will halt the current (java) thread for a given time. It’s done just once
  • It takes one argument in integer format
  • It waits just once at a command offered at sleep
  • For a particular amount of time, it stops the execution of all the selenium commands.
  • It takes one argument in integer format
  • Runs every command after setSpeed delay by a number of milliseconds stated in set Speed
  • This command is important for demonstration purposes or if you’re utilizing a slow web app

19. What’s the same origin policy and how you can avoid the same origin policy?

Same Origin Policy refers to a security mechanism that is implemented by web browsers to stop web pages from generating requests to a different domain than that which is served by a web page. In other words, the web page served from a single domain isn’t allowed to access resources like local storage, cookies, etc. on a distinct domain.

To prevent the “Same Origin Policy” proxy injection method is utilized, at proxy injection mode Selenium Server acts like a client-configured HTTP proxy, that sits in between the browser & the application under test & then masks the AUT under a fictional URL

Below are some of the few methods of avoiding the Same Origin Policy as you test with Selenium:

  • Utilize a Proxy Server: One method to bypass the Same Origin Policy is to utilize a proxy server to redirect a browser’s requests to a target domain. This is done by setting up a proxy server on the local machine & configuring a browser to utilize it.
  • Utilize Cross-Origin Resource Sharing (CORS): CORS refers to a mechanism that enables web pages served from various domains to request & access resources from every other. To utilize CORS, the server requires to be configured to enable cross-origin requests by sending certain headers in a response.
  • Utilize Selenium Grid: Selenium Grid refers to a distributed testing system that enables one to run tests on various machines & browsers in parallel. Through utilizing Selenium Grid, one could avoid the Same Origin Policy by running a test on a distinct machine than that which serves a web page.
  • Utilize a browser extension: Other browser extensions, like the CORS Everywhere, can be utilized to disable a Same Origin Policy for testing reasons.

20. What are heightened privileges browsers?

Heightened privilege browsers which are also understood as high privilege or elevated privilege browsers are web browsers that enable users to execute privileged operations on the local machine like accessing files plus executing system commands.

Moreover, these browsers are often utilized for testing purposes since they enable testers to interact with the underlying operating systems & test functionalities that aren’t available in regular web browsers.

In the context of Selenium testing, amplified privilege browsers are normally utilized to automate tests that require privileged access to a local machine like file downloads and uploads, accessing system registry, and interacting with desktop applications.

Examples of heightened privilege browsers are Internet Explorer which has Protected Mode disabled, Firefox which has Marionette or GeckoDriver, & Chrome browser with ChromeDriver in developer mode.

However, testers need to exercise caution when utilizing heightened privilege browsers, since they can introduce security dangers if not utilized well. For instance, when a tester operates a malicious script on a browser that has elevated privileges, the script will execute system commands & potentially cause damage to a local machine.

The best practice that the testers should utilize includes heightening privilege browsers just when necessary & guaranteeing that they have suitable security measures in place, such kind of running tests inside a sandboxed environment or utilizing virtual machines.


21. How one can utilize “submit” a form using Selenium?

To successfully submit a form utilizing Selenium, you can utilize the submit() method, that’s available on every element which represents a form or form control like the button or the link.

element.submit();

Alternatively one could utilize the click method at the element which doesn’t form the submission.


22. What are the TestNG features and list some of the functionality in TestNG which makes it effective?

TestNG refers to a testing framework for Java that offers a wide range of features for test automation like the support for data-driven testing, test reporting, and parallel execution. Some of the key features of TestNG include:

  • Data-driven testing: TestNG works with data-driven testing, which enables one to operate the same test with distinct data sets.
  • Annotations: TestNG offers a wide range of annotations that could be utilized to mark test methods, set up test dependencies, and configure test suites.
  • Parallel execution: TestNG works with parallel execution of tests that could assist in speeding up the test execution process.
  • Test reporting: TestNG offers detailed test reports like information on test outcomes, error messages, and execution time.
  • Flexible test configuration: TestNG enables one in configuring tests utilizing XML configuration files, programmatically, or through annotations.

Some functionality in TestNG that makes it very effective includes the:

  1. Test dependencies: TestNG enables one to set up dependencies in between test methods, which could assist in ensuring that tests are executed in the correct order.
  2. Groups: TestNG enables one to group tests, which could assist one in running certain tests or sets of tests.
  3. Parameterization: TestNG supports parameterization that enables one in running the same test with distinct parameters.
  4. Annotations for configuration: TestNG offers a range of annotations for configuring tests, like @BeforeTest, @BeforeClass, @AfterClass, and@AfterTest.
  5. Retry logic: TestNG enables one in configuring tests to retry when they fail, which can assist in ensuring that intermittent failures don’t cause false positives.

23. Mention what’s the difference between Explicit wait and Implicit wait.

In Selenium, the Implicit wait & Explicit wait are utilized to wait for elements to be available before performing an action on them. Moreover, there are some differences between them:

  • Explicit Wait: Explicit wait refers to a type of local wait that’s applied to a certain element. It enables one to wait for a given condition to occur before they proceed with script execution. The explicit wait refers to a set utilizing the WebDriverWait class, which offers a range of expected conditions that could be utilized to wait for an element to be available. Among the commonly utilized expected conditions includes visibilityOfElementLocated, titles, textToBePresentInElement, and elementToBeClickable.
  • Implicit Wait: Implicit wait refers to a kind of global wait that’s applied to every element in a script. This sets a timeout value for the WebDriver instance to wait for the element to be available. If the element isn’t found within the particular timeout, then the WebDriver would throw a “NoSuchElementException“. The implicit wait is set utilizing the driver.manage().timeouts().implicitlyWait() method.

24. Which attribute do you need to consider throughout the script in a frame for “if no frame Id as well as no frame name”?

When there is no name or id attribute available for a frame at Selenium, then you can utilize the driver.findElements(By.xpath(“//iframe”)). This returns a list of frames. You’ll require to switch to every frame & search for the locator which we need. After that break the loop.


25. Explain what’s the difference between find elements () & find element ()

At Selenium, findElement() & findElements() are two methods utilized in locating elements on a web page.

findElement() method gives the first matching element at the web page depending on the locator strategy utilized. When there is no matching element found, it will throw a NoSuchElementException.

findElements() method gives a list of every matching element on the web page depending on the locator strategy utilized. If there is no matching element available, it will then returns an empty list.

So, the major difference between these two methods is, findElement() gives a single web element, while findElements() gives a list of web elements.

Cross Browser Testing with Selenium WebDriver: A Comprehensive Guide


26. Explain what are the JUnits annotation linked with Selenium.

JUnit is a prevalent Java testing framework that can be integrated with Selenium to do automated testing. JUnit offers numerous annotations that can be utilized with Selenium in managing test execution, handling test suites, & more. Below are some JUnit annotations which are commonly utilized in Selenium:

  • @Before: This annotation is utilized in identifying a method that should be executed before every test method. You can utilize this annotation in initializing the test environment, opening a browser, or doing any setup operations.
  • @Test: This annotation is utilized in identifying a method as a test method that requires to be executed by JUnit. Moreover, one can specify the expected timeout, exception, and other attributes using this annotation.
  • @After: This annotation is utilized in identifying a method that should be executed after every test method. You can utilize this annotation to close a browser, clean up the test environment, or do any other teardown operations.
  • @AfterClass: This annotation is utilized in identifying a method that needs to be executed once after every test method in a class is executed. You can utilize this annotation in cleaning up the test environment, performing any one-time teardown operations, or releasing resources.
  • @BeforeClass: This annotation is utilized in identifying a method that should be executed once before any of the test methods in a class. You can use this annotation in setting up a test environment, or do any one-time setup operations.

27. Explain what’s Data-driven framework & Keyword driven.

Data-driven & keyword-driven are two main automation testing frameworks utilized with Selenium to do efficient & effective automated testing.

  • Data-driven Framework: In a data-driven framework, test information is stored differently from the test script. These test scripts are designed in a way that they can read information from external sources & perform tests accordingly. Data-driven testing includes creating test scripts that could run with numerous sets of test information, enabling you to test various scenarios & conditions.

The main benefit of a data-driven framework is it enables testers to compose test scripts that are more reusable plus easier to maintain. The reason being changes to test information can be made minus changing the test script, making it simple to add new test scenarios plus update existing tests.

  • Keyword-driven Framework: At a keyword-driven framework, keywords are utilized to represent test steps. These keywords are kept in a different data file that’s read by the test script to do the corresponding test steps. Every keyword represents a certain test action like clicking a button, verifying the contents of a web page, or entering text.

The major benefit of the keyword-driven framework includes it enables non-technical team members to compose test cases minus having to learn scripts or programming languages. It also makes it simpler to maintain & modify the test cases because of the changes which can be made to a keyword data file minus affecting the test script.


28. Explain how you can log in to any site if it’s showing an authentication popup for password & username.

Pass the username & password with the URL

ex- http://creyate:tom@www.gmail.com

Syntax-http://username:password@url


28. Explain the way you can assert the text of the webpage utilizing selenium 2.0.

To assert the text of a webpage utilizing Selenium 2.0, you can utilize the following steps:

  1. Set up Selenium WebDriver: Always ensure that you’ve successfully installed Selenium WebDriver & configured it to operate with a programming language that you prefer.
  2. Navigate to a webpage: Utilize the get() method to move to the webpage which you need to assert to the text on. For instance, driver.get(“https://www.example.com“).
  3. Get the element with text: Utilize the find_element_by_xpath() or find_element_by_css_selector() method to get the element at a page that contains the text which you need to assert. For instance, element = driver.find_element_by_xpath(“//div[contains(text(),’Hello World’)]”).
  4. Get the text of the element: Utilize the text attribute of an element to get text content. For instance, element_text = element.text.
  5. Assert the text: Utilize an assertion library like assert to make a comparing the text of an element to the anticipated text. For instance, assert element_text == “Hello World“.

29. Explain what’s the difference between Borland Silk & Selenium.

Borland Silk & Selenium are all software testing tools that are utilized in automating functional testing of web apps. However, there are numerous differences between the two tools.

  • Language support: Silk supports numerous programming languages, including C#, Java, Python, & JavaScript, while Selenium majorly supports Java, Python, and C#.
  • License: Silk is a commercial tool that needs a license to utilize, while Selenium is a free and open-source tool that’s available for free.
  • Cross-browser compatibility: All the tools support testing on several web browsers, but Silk features better cross-browser compatibility, unlike Selenium. Silk is capable of automating testing on various versions of the same browser, while Selenium requires extra configurations to achieve a similar level of cross-browser compatibility.
  • Object recognition: Silk utilizes a visual object recognition tech known as “Silk Test Classic” which could then recognize objects in web apps based on visual properties, while Selenium depends on Document Object Model (DOM) to find elements on a web page.
  • Integration: Silk could integrate with different third-party tools & platforms, including Jira, Jenkins, & Git, while Selenium features a limited set of integration choices.
  • Community support: Selenium features a large plus active community of developers and users who contribute to the tool’s development & offers support to different users. Silk features a smaller community of users & developers, and like a commercial tool, it may be extra difficult to get community support or online resources.

30. What’s Object Repository?

Object Repository refers to a term majorly utilized in software testing, particularly in the context of test automation. An object repository refers to a central location that keeps details about the different user interface (UI) elements of application software that are utilized in automated tests.

The function of an object repository is to offer a convenient means of managing manage and organizing the UI elements which are being tested which makes it simpler to create and maintain and update automated tests. Normally, an object repository refers to a file or a database that consists of a list of objects alongside their properties.

The objects at an object repository are normally the UI elements of a software application like the buttons, text fields, checkboxes, labels & other controls. The object repository keeps details about every object’s attributes like its name, class, ID, type, & location on a page.

Test automation tools, like Selenium & HP UFT (formerly QTP), make use of object repositories to keep plus manage objects at automated tests. During this test execution, the tool could retrieve the essential objects from a repository & do actions on them like clicking a button, verifying the text on a page, or filling in a form.

Object repositories are created manually, through recording test actions plus identifying objects on the page, or automatically, through utilizing tools that scan the page & generate object definitions. The use of object repositories assists in ensuring consistency & reliability in automated tests by offering a standardized way of identifying & manipulating UI elements.


31. Explain the way Selenium Grid works?

Selenium Grid refers to a tool that enables one to run Selenium tests in parallel across several machines & browsers. It operates by creating a hub & a node architecture where a hub acts like a central point in controlling & the nodes act like distributed execution environments.

Below are some of the basic steps of the way Selenium Grid operates:

  1. Start the hub: To begin utilizing Selenium Grid, you first require to start a hub. Hub refers to the central point of control which helps in managing the distribution of tests to nodes.
  2. Registering the nodes: The moment a hub is operational, one requires to register the nodes to it. Furthermore, nodes refer to machines where tests will be executed.
  3. Create the tests: Next, one requires to make the tests that you require to run in parallel. These tests could be composed in any programming language that is supported by Selenium including C#, Java, or Python.
  4. State the browser & node: In your test code, one requires to state the kind of browser and node on which you require to run the test. One will be able to achieve this by setting the Desired Capabilities of the RemoteWebDriver object in the code.
  5. Run the tests: After the test are ready, you will operate them by executing the test code on your local machine. Moreover, this hub allocates the tests to nodes reliant on the desired browser plus the node stated in the test code.

32. Can we utilize the Selenium grid for performance testing?

Yes. Although it’s not as efficient as a devoted Performance Testing tool including the Loadrunner. For instance, you can utilize Selenium to script the actions of a user on a web page, & then utilize a performance testing tool that helps in simulating numerous users performing a similar action simultaneously.

However, when utilizing Selenium for performance testing, it’s significant to have in mind that it could be resource-intensive & may not be best for testing apps at a high scale. Furthermore, it may not be as accurate as other dedicated act testing tools in measuring key performance indicators like response times, resource utilization, and throughput. Therefore, it’s recommended to utilize Selenium Grid together with dedicated performance testing tools for the best outcomes.


33. List the benefit of Webdriver over Selenium Server.

Selenium WebDriver is an improved and updated version of Selenium RC which is also known as Selenium Server. Among the advantages of utilizing WebDriver over Selenium Server include:

  • More stable & reliable: WebDriver is more reliable and stable, unlike Selenium Server. It utilizes the native support of every browser, which makes it to be less prone to errors & inconsistencies across various browsers.
  • Faster execution: WebDriver utilizes a more direct method of browser automation, which enables it to execute tests quicker than Selenium Server. Selenium Server depends on JavaScript commands that could be slower.
  • Support several browsers: WebDriver works with numerous browsers, unlike Selenium Server. WebDriver could also help in automating Chrome, Safari, Firefox, Edge, Internet Explorer, etc. Selenium Server just supports Firefox, Safari, Internet Explorer, & Opera.
  • Better API: WebDriver features a more user-friendly plus intuitive API, unlike Selenium Server. The API is simpler to utilize and understand, which makes it simpler to compose & maintain test scripts.
  • Better integration using testing frameworks: WebDriver integrates seamlessly with testing frameworks like TestNG & JUnit which makes it simpler to run tests and generate reports.
  • Enhanced handling of dynamic web pages: WebDriver features better support for handling dynamic web pages which utilizes Ajax, JavaScript, plus other advanced web tech. Selenium Server struggles with dynamic pages which leads to errors & flaky test outcomes.

34. Mention the capabilities of Selenium WebDriver or Selenium 2.0.

Selenium WebDriver which is also understood as Selenium 2.0, refers to a tool for browser automation that enables users in automating web apps for testing purposes. Among the key capabilities of Selenium WebDriver includes:

Support for numerous programming languages: WebDriver works with numerous programming languages including Java, C#, Python, Ruby, & JavaScript.

Simple deployment & configuration: WebDriver is easily deployed & configured on several machines which makes it a scalable and flexible tool for browser automation.

Cross-browser compatibility: Selenium WebDriver works with a wide range of browsers, including Firefox, Chrome, Safari, Internet Explorer, Edge, etc.

Advanced browser interactions: Selenium WebDriver allows improved browser interactions like mouse & keyboard actions, handling alerts & prompts, and taking screenshots.

Supports parallel test execution: WebDriver allows parallel test execution, which enables tests to be run parallel across several browsers & operating systems.

Support for numerous operating systems: WebDriver works with numerous operating systems which include Windows, Linux, and macOS.

Testing frameworks integration: One can integrate Selenium WebDriver with popular testing frameworks like TestNG & JUnit, which enables the creation of automated test suites plus test reports.

Integration with third-party tools: One can integrate a WebDriver with a third-party tool including Jenkins, to allow continuous integration & delivery.

Dynamic page handling: Selenium WebDriver could handle dynamic web pages which utilize JavaScript, Ajax, and other improved web technologies.


35. While injecting capabilities at webdriver to do tests on a browser which isn’t supported by a webdriver what’s the limitation that one can come across?

When one is injecting capabilities at WebDriver to do tests at a browser that isn’t supported by WebDriver, there are numerous limitations that one could come across. These include:

Inconsistent outcomes: Since the browser isn’t supported officially by WebDriver, the test outcomes may be inconsistent & unreliable which leads to false negatives or false positives.

Limited functionality: The web browser may not be completely supported by WebDriver, which means some features plus functionality may be unavailable for testing.

Lack of support: When an issue arises while testing on an unsupported browser, there may not be official support that’s available from a WebDriver team or browser vendor.

Maintenance overhead: Working with an unsupported browser might need extra effort plus maintenance overhead so updates to WebDriver or browser may lead to compatibility issues that require to be addressed.

Unforeseen compatibility problems: The unsupported browser can have compatibility issues with a testing framework and the operating system, or other software components and this could lead to unexpected failures or errors.


36. Explain how you can get broken images on a page utilizing the Selenium Web driver.

To get a broken image on a page utilizing Selenium WebDriver, we need to utilize the following steps:

  1. Get all image elements at the page utilizing the find_elements_by_tag_name method of WebDriver & pass the “img” tag name as an argument.
  2. Iterate the list of image elements & retrieve the source feature of every image utilizing the get_attribute method.
  3. Utilize the requests library in Python to send a request (GET) to the image URL & view the status code of a response. If a status code isn’t 200, this means that the image is broken.
  4. Print out the URL of a broken image if one is available.

37. Explain how one could handle colors in a web driver.

To deal with colors in WebDriver, one needs to utilize the getCssValue(arg0) function to have the colors by sending the ‘color’ string as an argument

This offers means of manipulating colors in various formats like RGB, HSL, or HEX.


38. Utilizing a web driver how can one store a value which is a text box?

You could utilize the following command to keep a value which is a text box utilizing the web driver


39. Explain how can one switch between frames.

To successfully switch in between frames the webdrivers [ driver.switchTo().frame() ] method takes one of three possible arguments

An ID or name: choose a frame by its ID or name

A number: It chooses the number by zero-based index

Previously found WebElement: Utilizing its previously found WebElement choose a frame


40. Mention Five different exceptions you had at Selenium web driver.

Below are the five different exceptions that can occur while utilizing Selenium WebDriver:

  • TimeoutException: This exception is raised the time a WebDriver is unable to get an element within a stated timeout period. This could happen if an element is taking a long to load or when the locator strategy isn’t correct.
  • NoSuchElementException: This exception is raised the time a WebDriver is not able to find an element utilizing a particular locator strategy. This happens when an element doesn’t exist on the page or when the locator strategy is inappropriate.
  • ElementNotVisibleException: This exception is raised the time a WebDriver isn’t able to interact together with an element the reason being it’s not visible on the page. This can occur when the element is hidden or when it’s located outside of the visible area of a page.
  • WebDriverException: This exception is an overall catch-all for every error that happens while utilizing WebDriver. This occurs when there is an issue with a WebDriver server or when there’s a bug in the WebDriver library itself.
  • StaleElementReferenceException: StaleElementReferenceException is raised the time an element no longer attaches to the page’s DOM. This happens when the page is refreshed or when the element is modified or removed by a script.

41. Explain utilizing Webdriver and how one could perform double click

At WebDriver, we can double-click at elements utilizing the ActionChains class. This class offers a means to chain numerous actions together & execute them as one operation.

One could perform double click through using

Syntax- Actions act = new Actions (driver);

act.doubleClick(webelement);


42. How will one utilize Selenium to upload a file?

To upload a file utilizing Selenium, we could interact with the file upload input element on the web page utilizing the send_keys() method, which simulates typing of a file path to the input element.


43. Which of the web driver implementation is the fastest?

HTMLUnit Driver implementation is quickest, HTMLUnit Driver doesn’t execute tests on a browser although a plain HTTP request that’s far quicker than initiating a browser & executing tests