Selenium Interview Questions and Answers
Share This Post
Selenium Interview Questions and Answers
Are you interested in knowing about jobs with automation knowledge? The automation industry is undergoing frequent changes with the requirement of specialized talent. RPA, machine learning, IoT, Artificial intelligence, and Selenium, QTP, and load runner are the concepts connected to automation. Selenium is one of the popular tools among web app automation which is designed for the functional testing.
Frequently asked Selenium Interview Questions and Answers are listed below for students who are preparing for the Selenium interviews. Automation is the term that is connected with devices, browsers, servers, and programming languages. As it is an open-source tool many companies use Selenium and it is easy to learn Selenium. Selenium supports many programming languages like Java, Ruby, C#, PHP, Python, and Perl. Python Selenium Interview questions and Java Selenium Interview questions provide Selenium usage along with Python and Java.
If you are ready to spend time every day then learning selenium will be completed within a week or two. Scroll down to know the 50 most popularly asked Selenium Interview questions and answers framed by our experts to attend Selenium interviews after completing Selenium Training.
Best Selenium Interview Questions and Answers
Selenium is the automation tool used for testing web-based applications. There are four components in Selenium to take care of different needs of automation testing. The features of these components are it supports multiple browsers, aid for parallel testing, and aids for handling multiple machines. Selenium is the best tool as it automates with speed and increases the performance of the website. The integrated development environment, Selenium RC, Selenium Grid, and Selenium WebDriver are the four components of Selenium.
In the year 2004 Selenium is developed by Jason Huggins. He is an Engineer working with Thought work for testing the web application which requires frequent testing for better quality. After joining Google he continued the development of RC and then released the new project called Selenium WebDriver or Selenium 2.0.
Selenium IDE, Selenium RC or Selenium 1, Selenium WebDriver or Selenium 2, Selenium 3, Selenium Grid, and Selenium are the different versions of Selenium. Top Selenium Interview Questions and answers from CourseJet are curated to cover all the versions of Selenium.
- It saves time and money
- It is helpful to test multilingual sites.
- It requires less human intervention.
- The area of coverage used for automation testing is vast than manual testing.
- Manual testing is prone to error and automation testing reduces errors.
Automation testing is used in cases where there is a high risk, repetitive tasks are needed, tedious tasks that take more time manually, and test cases that are not frequently changing.
Selenium supports major browsers like Google Chrome, Safari, Firefox, Opera, HtmlUnit, Phantomjs, iOS, and Android.
- QTP is a paid tool and used for UI based testing, database testing, and file operations.
- VB Script knowledge is required for QTP and it is used largely as it provides ease navigation, generates reports quickly, and shows result validation.
- Selenium is the open-source tool used for functional testing and regression testing.
- Selenium can be connected to other tools like JUnit, Jenkins, Docker, Maven, and Test NG.
This question is for experienced candidates and beginners it can be on an assumption basis. Those who are working in the software testing industry automate 2 to 3 test cases per day. It depends on the complexity associated with the test scenarios like simple and difficult.
Selenium1 is nothing but RC which works with JavaScript. Selenium 2 is developed to design selenium for different browsers with high speed. Selenium 3 is tightly coupled for all the web Driver implementations like Microsoft, Google, Apple, and Mozilla. The feature of tight coupling gives a better testing performance in the case of Selenium 3.0.
Selenese commands are used to perform various functions like checking the UI elements, check for the links, handle the data and fields, and check to drop-down list, scroll down a page and switch between windows. Actions, Accessors, and Assertions are the three types of Selenese commands used in the scripting language. Actions for changing the state of the application, accessors for saving the results, and checking the status, assertions are for checking certain checkpoints.
Looking for Best Selenium Hands-On Training?
Get Selenium Practical Assignments and Real time projects
Selenium IDE aid in reducing the time which is spent on creating the test cases and editing the test cases. As it supports multiple types of extensions it is easy to do editing and it is also user-friendly. Selenium IDE supports only Firefox browser with the prototyping tool and it does not work for condition or iteration statement which is essential for remote execution. For supporting the remote control the testers invented Selenium RC in the year 2007.
To slow down the execution of test wait or sleep can be used within WebDriver. If the execution needs to wait for a particular time then the explicit or implicit wait can be used.
Selenium is for browser automation and not used for API testing. Some of the tools which support API testing are REST, JMeter, SoapUI, and Postman. API testing is for system integration whereas functional testing is for testing browsers for different scenarios. API testing and Selenium testing both come under black-box testing.
A Framework is the set of rules for getting desired results systematically. The results or best practices from the testers are grouped as frameworks. Readability of the code and reusability of code from Frameworks makes the job of testers easy. The different types of Selenium frameworks are Hybrid, keyword-driven framework, behaviour-driven framework, data-driven framework, modular testing framework, and linear scripting framework. The Data driven framework works with the separation of test data, and scripts whereas the keyword driven framework works with keywords, test data and test scripts with step by step information. Selenium Framework interview questions Cover all the questions related to Selenium Frameworks.
HTMLUnitDriver is the fastest API as it is not executed using the browser but it is executed with a mechanism or request and response. It is also called a headless browser as it executes without browser.
There are two types of waits which word with the condition and time for the execution. The explicit wait is used if a certain condition needs to be checked and the implicit wait is used if the WebDriver needs to locate an element and then proceed with the execution.
The exception is the object which makes the flow of the testing program to stop. Creating the object for the exception and handling the run-time is called throwing the exception. Different types of Exceptions are ElementNotVisibleException, ElementNotSelectableException, InvalidSelectorException, NoSuchElementException, NoSuchFrameException, NoAlertpresentException, NoSuchWindowException, StateElementReferenceException, SessionNotFoundException, TimeoutException, and WebDriverException. Let us comprehend about each.
- ElementNotVisibleException some elements are defined as “hidden” but present in DOM
- ElementNotSelectableException some element are disabled from click or select function
- InvalidSelectorException some elements are used to show invalid and does not show WebElement
- NoSuchElementException the FindBy method of the WebDriver unable to find the element which is required for the runtime
- NoSuchFrameException Invalid Frame
- NoAlertpresentException Invalid alert
- NoSuchWindowException invalid window
- StateElementReferenceException referred element goes to the different frame to show exception
- SessionNotFoundException WebDriver performs quitting of the browser
- TimeoutException command is not working within a specified time
- WebDriverException exception which is caused due to the close of the browser by the WebDriver immediately after acting.
Assertions are the validations to know whether a test is pass or fail. There are two types of assertions and they are hard and soft assertions.
X path is the syntax that is used to find an element from the web page through the XML path. There are two types of X-path called as absolute X-path and relative X-path. When automating web application XPath Axes are used for dynamic elements.
Become Selenium Certified Expert in 35 Hours
Get DevOps Practical Assignments and Real time projects
After the installation of WebDriver locator aid the testers to select an HTML DOM from the web page. CSS ID, CSS class, partial link text, link, name attribute, Xpath or DOM structure, and HTML tag are the different types of locators used in HTML to locate elements.
There are two types of Xpath and they are absolute Xpath and relative Xpath. Absolute Xpath is denoted with a single slash and the coverage of the node shows that it assumes node as a direct child of the current. The relative path starts with the symbol of double slash which shows it finds out the parent node in the HTML tree and then matches the element with locator.
The different objects on the web page are stored in the object repository with key-values. Key is the name of the object and value is the properties of the object. Hence, the object repository is the centralized system that stores the locator values and acts as a map for mapping the UI element. This helps for the separation of the external file and making changes with the locator values. If the value of the locator got changed then no need to search the object or make the changes with the test cases instead changes can be made in the object repository.
Breakpoint and start point are the two points used to observe the behaviour of the test with start and pause functions. There can be many breakpoints whereas the start point is the one for a single test script.
In times of failure assert or verify commands work in Selenium. Assert handle the failure with the abortion of the execution and failure of the test. Verify handle the failure with one side as a failure of the test but continue to process the test case till execution.
Proxy is the central body for interactive systems which enhances privacy and encapsulation. Proxy is used to redirect browsing through changing the settings of proxy manually or changing the setting using the code of web driver.
The page object model is the design that stores the web UI elements as an object repository. As the objects are stored it becomes easy to maintain the objects and reduces duplication of code. Page factory is one of the methods for the creation of the POM concept with an object repository.
POM introduces the decoupling layer which makes it easy to handle the changes in the UI breaks. The changes with the UI are updated using classes and page objects. The separation of the test and locator element makes it easy to maintain. It is easy to integrate tools like PHPUnit, Nunit, or JUNIT as this repository is independent. POM classes make the test cases as short and programmer-friendly. It is more comprehensive and durable.
JavaScriptExecutor is used when the click() method cannot execute and it works with Selenium driver classes like FirefoxDriver, InternetExplorerDriver, ChromeDriver, EdgeDriver, OperaDriver, SafariDriver, RemoteWebDriver, and EventFiringWebDriver for the execution. Due to the policies of cross-browser sometimes execution script fails and two methods of JavaScriptExecutor such as executeScript() and executeAsyncScript() are used.
Selenium is for web application testing and it does not support applications that are windows based. Alert interface of WebDriver aids the users to handle the Pop-ups of Selenium. Dismiss() and void accepts () method functions with the cancel button and ok button as soon as the pop-up windows appear.
Become a master in Selenium Course
Get Selenium Practical Assignments and Real time projects
Selenium Grid is used along with RC for running test cases on the machines that are located remotely. The architecture of Grid is Hub-node which is like one hub and other nodes as slaves. It is easy to run huge test cases with different operating systems and browsers using Selenium Grid.
MaxSessions are used in case of maximum execution of test cases inside a node at the same time but Maxinstances are for a specific type of browser.
Both the commands are similar but not the same. driver.Quit() is used to exit the multiple tabs or windows or pop-ups or browser. diver.close() is for a closing window that has focus. If multiple tabs or windows are open then it is good to use driver.close().
The four elements associated with the conditions of a test are URL, host, browser, and port number.
IAnnotationTransformer, IAnnotation Transformer 2, IConfigurable, IConfigurationListener, IInvokedMethodListener, IInvokedMethodListener2, IExecutionListener, IMethodInterceptor, IHookable, IReporter, ITestListener, and ISuiteListener are the different listeners of TestNG.
Selenium needs backend interaction to deal with the database. The API which is used to get data and interact with the database in Selenium is JDBC.
The main difference between Xpath and CSS is the movement when searching for elements. XPath moves backward and forward and it is used to locate parent element and child element. CSS is used to move forward.
Some of the elements which are used to improve the speed of the scripts are used fast selectors, create an atomic test, use less number of locators, duplication of testing functionality twice, quality of test case, usage of explicit waits, if the browser is headless then the driver can be used, use chrome driver, re-use the instance of a browser, run parallel scripts, Use HTTP libraries, use less number of images and pre-populate cookies.
Robot class is used if control is required with mouse and keyboard, to generate input events for the native system, and self-running demos, and to handle OS popups Robot class is used.
The listener is used to modify the behaviour of TestNG and allow customization inside TestNG reports. The events of Selenium are listened by Listeners and accordingly bring customization by default.
Looking for Selenium Hands-On Training?
Get Selenium Practical Assignments and Real time projects
Tests are executed in an organized manner with order and this order of execution is handled by testing.xml file. It is the file that defines the test suites with parameters. Multiple tests can be grouped in a single test suite and initiate a multi-threaded environment.
The difference between soft assert and the hard asset is error handling. Soft assert collect errors and does not show the exception. Hard assert handle the error with an Assertexceptionimmediately statement.
The architecture of the Selenium web driver consists of the logic required for the different types of drivers. The different components required for Selenium web driver are Selenium Client Library, Browsers, Browser drivers, and JSON WIRE PROTOCOL over HTTP client.
get() method is used to retrieve the values of CSS properties. CSS is used to identify elements in Selenium like X path but CSS is faster than X path.
Find Element command is used to find an element and it can also be integrated with locator strategies like Name, ID, Class, X path, and Class name.
The different types of testing used in Selenium are functional testing, sanity testing, regression testing, and smoke testing, cross-browser testing, responsive testing, UI testing, and integration testing.
Selenium grid is used in cases where test handles different browsers, different operating systems, and different machines at the given time. The second scenario where Selenium Grid is needed is when saving time is essential. By using the Selenium Grid test can be finished 4 times faster.
Selenium Grid’s main function is to run the test in different browsers. So, it uses the concept of hub and node which means the hub is the central point which consists of a load of many tests, and a node is the execution point that loads the tests from the hub.
The prominent API that selenium tester should be aware of are Navigation commands, deleting cookies, resizing windows, closing the browser, searching webElements, Get methods, locators, frame handling, wait for a command, window handling, mouse operations, alert handling, and working with dropdowns.
Selenium is used only for web applications and it is not used for mobile applications, readers of captcha and barcode are not included in Selenium testing, in case of problems when using selenium vendor support is not there as it is the open-source tool, and reports of Selenium are prepared using tools like TestNG or JUnit which is the third party tool are some of the limitations in Selenium.
Are you interested in learning Selenium from experts?
Get Selenium Practical Assignments and Real time projects
Intermediate Selenium Interview Questions and Answers
Every element on a web page is referred to as an element in Selenium. There are various ways to find an element on a web page using Selenium. They are
- Name
- ID
- Linktext
- Tag
- CSS
- Xpath
- Attribute
The technical challenges that we usually face with Selenium are
- Selenium will not support bitmap comparison.
- Selenium only supports applications based on the web.
- Maintaining components is very difficult because there is no concept of an object repository in selenium.
- For capabilities like reporting, we have to depend on third-party tools.
In most of the cases, TypeKeys() will trigger JavaScript events whereas .type() will not. Type keys are used to populate the value attribute in JavaScript, whereas .typekeys() remove actual user typing.
We use annotations to specify a cluster of code embedded in the program. Annotations make the Selenium script more manageable. Few useful JUnit annotations are
- Test
- Before
- After
- Before class
- After class
- RunWith
- Ignore
Yes, we can use screen coordinate while using the click command. For example, whenever we are clicking on a specific section of an element, we have to use the clickAT command. This clickAT command receives element locator and x, y coordinates as arguments. clickAt (locator, cordString).
‘Same-origin policy’ is primarily introduced for security purposes. It makes sure that the script from another site cannot access the content of one’s site.
Below are few functionalities that make TestNG effective
- Data-driven testing is supported.
- The test configuration is flexible.
- Annotations are supported.
- Failed test-cases are re-executed.
The implicit wait will set a time-bound to search the elements it repeatedly searches until the time is out. If it doesn’t find that element within the time-bound, it displays the NoSuchElementException.
The explicit wait is a one-timer used for a specific search.
The five different types of exceptions in selenium are
- NoAlertPresent Exception.
- WebDriver Exception.
- Timeout Exception.
- NoSuchElement Exception.
- NoSuchWindow Exception.
In AWS we typically use templates such as JSON or YAML. And these comprise of following five important elements:
- Output values
- Template parameters
- Resources
- Data tables
- File format version
Looking for Selenium Practical-Oriented Training?
Get Selenium Practical Assignments and Real time projects
Beta1 updates of Selenium 3.0 are
- Selenium will support Firefox through Mozilla’s gecko driver.
- The minimum version of Java is 8+.
- Usually, it supports Safari on macOS through Apple’s own safari driver.
- MS supports Edge.
Verify command is used to check if an element is present on the page or not. If the element is not there on the page, the test will carry on the execution. In verification, all the commands are going to run even if any of the tests fail.
Assert command enables you to check if an element is present on the page or not. The test will stop if the element is not found. If the test fails. In other words, we can say that the test gets terminated when the check fails at a specific point in time.
The heightened privileges are similar to proxy injection. This permits websites to do something which is generally not permitted. The primary difference is browsers originate in a specific mode called heightened privileges. Elsewhere, by utilizing this mode of the browser, the Selenium core will directly open the AUT and write/read the content without passing the entire AUT via the Selenium RC server.
- @Before public void method().
- @After public void method().
- @Test public void method().
There are many reasons why Selenium is better than Borland skill. A few of them are:
- Unlike Borland skill, Selenium is entirely free.
- Selenium is flexible to use various languages like Java, Perl, Ruby, etc., whereas Borland skill uses only scripting language.
- Borland supports only Firefox and internet explorer, whereas Selenium supports many browsers like Opera, Safari, Internet explorer. Firefox, and so on.
We don’t need a Selenium server if we are using Selenium Webdriver because it uses completely different technology.
Selenium web drivers make direct calls to the browser, whereas Selenium RC needs a Selenium server to insert JavaScript within the browser.
Firstly, by using the tag name get Xpath and get all the links within the page.
Click on each and every link on the page.
Look for the errors 500/404 within the target page title.
There are five different exceptions we will find in the Selenium web driver, and they are:
- WebDriverException
- NoSuchWindow Exception.
- NoAlertPresent Exception.
- Timeout Exception.
- NoSuchElement Exception.
We can perform double click using a web driver like this:
Syntax- Actions act = new Actions (driver);
act.doubleClick(webelement);
Become a master of Selenium in 35 Hours
Get Selenium Practical Assignments and Real time projects
Automation testing utilizes various automation tools to write and execute test cases; no manual engagement is needed to execute a particular automated test suite. Testers generally prefer the automation tools to write test scripts plus test cases and then grouping them within test suites.
Automation testing permits the usage of various tools in order to automate the execution of manually created test cases without human interference. Different types of automation testing tools can obtain the test data, manage the execution of tests, and compare the genuine result versus the expected result. Consequently, creates specified test reports of the system under test.
Operating systems: Linux, MAC, ios, android, Solaris.
Programming languages: C#, python, java, PHP, Javascript.
Browsers: Firefox, Internet Explorer, Opera, Google chrome.
We use the get() command to get the text of a particular web element. The get command does not need any parameter, but it Returns a string type value.
String Text = driver.findElement(By.id(“Text”)).getText();
WebDriver enables the user to monitor the visibility of the web elements. These web elements can be radio buttons, buttons, drop boxes, checkboxes, labels, etc., which are utilized with the following methods.
- isDisplayed()
- isSelected()
- isEnabled()
- Handling captcha
- Limited reporting
- Handling page load
- Handling dynamic elements
- Handling pop up windows
- We cannot test mobile apps
The testing types that are supported by Selenium are:
- Functional testing
- Sanity testing
- Smoke testing
- Responsive testing
- Cross-Browser testing
- UI testing
- Acceptance testing
- Integration testing
In Selenium IDE, we utilize Selenese Verify plus Assert Commands as Verification points. Within Selenium WebDriver, there are no built-in features in concern with verification points. It ultimately depends on our style of coding. Some of the Verification points are:
- To check for specific text.
- To check for the page title.
- To check for a specific element.
searchContext is the super interface of the Web driver
public interface x{
void dosomething();
}
public interface y{
void dosomethingelse();}
In the above example, x is the super interface of y. It is the same as being a superclass.
FluentWait can determine the maximum quantity of time to wait for a particular condition, including the frequency among which to check the condition before throwing an “ElementNotVisibleException” exception.
According to the official Selenium documentation, it is recommended not to mix both Implicit waits as well as Explicit Waits. Combining both of them can cause inconstant wait times.
The implicit wait is defined only once within the code. It will continue to be the same during the driver object instance.
The explicit wait can be defined in the code whenever it is needed. This wait will be called during the time of execution. It is also known as a conditional wait.
The main function of Explicit wait is to overwrite the Implicit wait wherever it finds its implementation. So this is the reason why the Explicit wait gets the first preference or priority than that of Implicit wait.
Our Recent Blogs
Related Searches
selenium interview questions selenium interview questions and answers selenium engineer interview questions selenium interview questions and answers for experienced selenium interview questions for 3 years experience selenium interview questions pdf selenium interview questions and answers for experienced pdf selenium basic interview questions selenium interview questions for experienced selenium interview questions and answers pdf selenium interview questions for freshers selenium real time interview questions selenium manager interview questions selenium interview questions for 2 years experience selenium interview questions and answers for freshers top selenium interview questions