Selenium Interview Questions and Answers

Selenium Interview Questions and Answers

Selenium Training in Chennai provides training in the web driver, IDE, grid, and continuous integration testing. Agile methodology and DevOps work culture are highlighting the need for testing in the software industry. Different tools like Selenium, testingWhiz, HPE Unified functional Testing, TestComplete, Ranorex, Sahi, Watir, and Tosca test suite are used for the different types of testing projects. Let me discuss in detail about the interview questions for Selenium Training.

  1. What are the different types of automation testing?

Regression testing, smoke testing, and sanity testing are different types of automation testing.

  1. What are the maximum numbers of test cases that can be automated per day?

The number of test cases automated per day by the tester depends upon the complexity of the web application. In general, it is estimated that tester automates 2 to 5 test scenarios per day if the complexity is low. One or fewer test cases are expected if the complexity is high. Selenium Course in Chennai helps to prepare for the interviews with the practical oriented training.

  1. What are the different types of the testing framework?

Data-driven testing framework, keyword driven testing framework and hybrid testing framework are the three types of testing frameworks.

  1. Explain the process of how the automation framework is used?

The test automation framework starts with the process as the programming language, framework used, test base class, element locators, tests- page objects, page factory, utility functions file, property files, Test NG annotations, how we parameterize tests using excel files, Test NG annotations, parameterize tests using excel files, error screenshots, generating reports, e-mailing reports, version control system used and continuous integration tool.

  1. What are the reasons to select the selenium automation tool?

Free and open source, have a large user base, cross-browser compatibility, platform compatibility, and the support to the multiple programming languages such as Java, pearl, Python, PHP, and C#.

  1. What are the components of selenium?

Selenium IDE, Selenium RC, Selenium WebDriver, and selenium Grid are the four components of selenium.

  1. Explain Selenium IDE?

Selenium IDE is the firefox plugin and simplest framework in the selenium suite. Selenium IDE is used for creating scripts or test cases and Selenium RC or selenium Web Driver are used for more advanced or robust test cases.

  1. Explain Selenese?

In the selenium IDE, selenese language is used to write the test scripts. Best Selenium Training in Chennai aid the students to get placed in the top companies.

  1. Which browser supports selenium IDE?

FireFox is the only browser which supports the selenium IDE.

  1. Explain Selenium Web Driver?

Selenium Web Driver AKA selenium 2 accepts the commands and sends them to a browser. It directly communicates with the browser and it is implemented through a browser-specific driver. Selenium Web Driver supports multiple languages like Java, C#, PHP, Python, Perl, and Ruby and it is the framework for automating the web application.

  1. Explain the Selenium Grid?

Selenium Grid is used to run the tests in different machines against the different browsers and it is used together with Selenium RC. It is used to run the test in multiple platforms and environments like different machines, different browsers, and different operating systems.

  1. Describe the hub in Selenium Grid?

A hub is a server which controls the test execution in multiple machines.

  1. Explain node in Selenium Grid?

Node is the machine which is attached to the hub and there can be multiple nodes in a single selenium Grid. Best Selenium Training Institute in Chennai with the best reviews from the students conducts the classes with peer approach and practical approach.

  1. List the different types of Web Driver APIs available in selenium?

Firefox Driver, Gecko Driver, Internet Explorer Driver, Chrome Driver, HTML Unit Driver, Opera Driver, Safari Driver, Android Driver, iPhone driver, and event firing web driver are some of the Web Driver APIs in selenium.

  1. Name the open-source frameworks supported by the Selenium WebDriver?

JUnit and TestNG are the open-source frameworks supported by the selenium web driver.

  1. What are the locators available in the Selenium WebDriver?

ID, ClassName, Name, Tagname, LinkText, PartialLinktext, XPath, and CSS selector are the locators in the Selenium Web Driver.

  1. Which web driver is the fastest web driver?

The HTML unit driver helps for the fastest implementation of the web driver. The HTML unit driver does not execute the tests in the browser.

  1. Name the programming languages which selenium supports?

The programming languages which selenium support are Java, C#, Python, Ruby, Perl, and PHP are the programming languages used in the selenium.

  1. List out some of the disadvantages of the selenium testing?

Selenium is not used for the windows application and mobile apps, the reporting tools are limited, it handles dynamic elements, it is difficult to handle the page load, pop-up windows and the captcha are difficult to handle in the selenium.

  1. Describe the XPath?

To locate the elements XPath is used. In an XML document to locate the web elements XPath is used. Textbox, button, checkbox, and image are the web elements in a web page.

  1. What is the difference between single slash and double slash in selenium?

Single slash is used to create XPath with the obsolete path and the X Path is used to create the document from the node or the start node. Double slash is used to create the X path with relative path and X path is used to select anywhere within the document.

  1. Differentiate between the absolute path and the relative path in selenium?

The process of the absolute path is from the root node until the desired descendant element’s node. The process of the relative path is it starts from the HTML node and ends with input node.

  1. Differentiate assert and verify in selenium?

The condition in the assert is true then the program will execute the next step in the test and if it is false then it will stop. Similarly, in Verify there is no connection between the condition and the test execution.

  1. Explain the soft assert and the hard assert in selenium?

The soft assert collects the errors and it does not throw an exception when an assert fails whereas hard assert throws an Asser exception immediately and the test suite continues after the assert statement fail.

  1. Mention the verification points in the Selenium?

The verification points in the selenium are the page title, certain text, and the certain element are some of the verification points. There is no coding for the verification and it is the built-in feature of the selenium

  1. Explain how text is derived in the web element?

The getText() method is used

package softwareTestingMaterial;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.annotations.Test;

public class TestTestTest {

 @Test

 public void testmethod(){

 System.setProperty(“webdriver.chrome.driver”, “D:\\Selenium Environment\\Drivers\\chromedriver.exe”);

   WebDriver driver = new ChromeDriver();

   driver.get(“https://www.google.com”);

   String availableText = driver.findElement(By.xpath(“//*[@id=’gbw’]/div/div/div[1]/div[1]/a”)).getText();

   System.out.println(“Text Available is :”+availableText);

  1. How to run the web driver scripts in the selenium?

To distribute the selenium webdriver scripts in the selenium the selenium grid selenium server is used.

  1. Explain the meaning of the command driver.get (“www.softwaretestingmaterial.com”) in the selenium?

The meaning of this is that an exception is thrown and it is required to pass HTTP protocol within the driver.get() method. driver.get.

  1. How to open an URL in Selenium WebDriver?

driver.get() method is used to open an URL in the Selenium WebDriver and the alternative method is driver.navigate.to (“URL”).

  1. Differentiate driver. get () and driver.navigate.to(“URL”) in the WebDriver?

driver.get() is used to open an URL and till the page gets loaded it will wait whereas in the case of the driver.navigate.to() the URL will not wait till the whole page gets loaded. driver.navigate.to() is used to navigate an URL.

  1. What are the methods used to move back, forward and refresh a page in the Selenium WebDriver?

driver.navigate().forward(); is used to navigate forward as per the browser’s history, driver.navigate().back(); is used to move back with reference to the browser’s history, driver.navigate().refresh(); is used to refresh the current web page and helps to reload the web elements, driver.navigate().to(“URL”); is used to launch a new web browser window and navigate to the specified URL in the selenium.

  1. What is the command to fetch the current page URL in Selenium?

The get current URL () is used to fetch the current page URL and the command is driver.getCurrentUrl();

  1. How to maximize the browser window in the selenium?

The browser window in selenium is maximized with Maximize() method.

  1. What is the method used to delete cookies in Selenium?

delete all cookies() method is used to delete the cookies in the Selenium.

  1. Mention the different ways to refresh a browser in the Selenium WebDriver?

driver.navigate(), driver.getCurrentUrl(), and driver.navigate(), and the sendkeys are used to refresh a page in the Selenium.

  1. State the difference between the driver.getWindowHandle() and driver.getWindowHandles() in Selenium WebDriver?

driver.getWindowHandle() returns a handle of the current page driver.getWindowHandlesis used to return a set of handles of the all the pages available in the web driver.

  1. Explain Page object model in selenium?

Page object model is a design pattern used for the maintenance and code duplication. POM serves as an interface to the UI and if the UI has changed then no need to change the test it is enough to change only the coding part located in one place. A page object supports the modular, data-driven, keyword driven, hybrid framework in the selenium.

  1. Describe the term page factory in selenium?

Page object model is the reference page for every page and it is used to represent an application in a test framework. Page factory is used to implement the page object model in the selenium.

  1. State the difference between the page object model and page factory?

Page factory is used for the communication between the web elements and page object when creating an instance of it. The page object is used to represent the web page, functionalities details and members of the web page.

  1. List out the advantages of the page object model framework?
  • The code one used can be reused in different types of tests
  • It is easy to maintain the code as there is a separation in the test code and page specific code. This feature helps for the code separation and easy to make changes in the coding top run multiple tests.
  • Each page is called as java class and each field in the page is called as members in the object repository. The class will implement the interface in the selenium.
  • As there is a separation in the test code and the page code the readability aspect is good.
  1. What is the coding used for the recovery scenario in the selenium web driver?

“Try catch block” is used in the selenium web driver for the recovery scenario.

  1. List out the methods to upload a file in the selenium Web Driver?

There are two methods and they are Send Keys method and auto IT script method in the selenium. These two methods are used to upload a file in the selenium.

  1. Mention the method used to download a file in the selenium Web Driver?

The method used to download a file in the selenium is Auto IT script method.

  1. Mention the coding to run the selenium web driver from the command line?

Java program and Test NG are used to run the selenium web driver in the command line.

  1. What is the code to switch the frames in the selenium?

driver.switchTo().frame(); is the code used to switch the frames in the selenium.

  1. Mention the driver used to connect the database in selenium?

Selenium is used to automate the user interface. JDBC driver from Java programming language is used to connect the database in the selenium web driver.

  1. Which class is used in the selenium web driver to resize the browser window?

Dimension class is used in the selenium to resize the browser window in the selenium web driver.

  1. Which method is used in the selenium to scroll the page up or down in the selenium web driver?

Javascript scroll By () is used to scroll with a specific number of pixels in the selenium.

  1. Which class is used in the selenium for the right click action?

The actions class is used for the right click in the selenium web driver.

  1. Which class is used in the selenium for the double-click action?

Action class is used for the double click action in the selenium.

  1. Which class is used in the selenium to automate the drag and drop action?

Actions class is used in the selenium to automate the drag and drop action from one place to another place in an application.

  1. Which interface in the selenium is used to highlight the element in the selenium web driver?

Javascriptexecutor interface is used in the selenium to highlight the specified element.

  1. Which tool is used in the selenium to run scripts on the cloud?

Browserstack is used in the selenium to run tests on multiple browsers and multiple operating systems in a cloud environment.

  1. Explain the term desired capabilities in the selenium?

The desired capabilities are used to handle the SSL certificates in chrome browser.

  1. Why selenium is called continuous integration?

Continuous integration is used to check the quality of the software continuously after the software development. Some of the tools used for continuous integration are Jenkins, TeamCity, bamboo, Travis, circle ci, and bitbucket.

  1. What is TestNG?

TestNG is used for unit testing and integration testing and it is a simplified framework for the different testing needs.

  1. Mention the annotations in the TestNG?

@BeforeTest, @AfterTest, @BeforeClass, @Afterclass, @BeforeMethod, @AfterMethod, @Beforesuite, @Aftersuite, @BeforeGroups, @AfterGroups, and @Test are some of the annotations in the TestNG.

  1. Mention the assertions supported by the TestNG?

asserEqual, assertEqual, assertEquals, assertTrue, assertTrue, assertFalse, and assertFalse are some of the assertions supported by the TestNG.

  1. Mention the method to set the test case priority in TestNG?

The priority attribute @ Test annotations and the test scripts execute in alphabetical order are used to set the test case priority in the TestNG.

  1. How to handle multiple test classes in selenium?

In TestNG XML file is used to create and handle multiple test classes. The steps followed are configured the test run, set test dependency, include or exclude any test, method, class or package and finally set the priority in the XML file. Mention the method to set the test case priority in TestNG?

The priority attribute @ Test annotations and the test scripts execute in alphabetical order are used to test case priority in the TestNG.

  1. Mention the types of testing in selenium?

     Functional testing and regression testing are the two types of testing supported by the selenium automation testing.

  1. List out the challenges faced by the programmers when using selenium?

Some of the challenges or disadvantages in using the selenium automation tool are Selenium is not applicable to the mobile based applications, selenium is not applicable to the captcha and barcode readers, Selenium is not used to generate the reports and third-party tools like testNG or JUnit are used to prepare the reports.

  1. What is origin policy in Selenium?

Origin is the combination of scheme, host, and port of the URL. The origin policy in selenium is that it accesses the elements only from an origin and not from other domains like google.com or seleniumhq.org. So, Selenium RC is used to handle the same origin policy.

  1. What are the purposes of the HTTP Server?

Read HTTP requests, determine the steps for implementing the selenium command, send the implementation steps, From the browser receive the execution status, and inform the client regarding the execution status are some of the functions of the HTTP Server.

  1. What is the difference between implicit and explicit wait in selenium?

The implicit wait is used to provide a waiting time of 30 seconds for the entire test script. The explicit wait is used for the halt in execution until the condition is met.

  1. Explain the coding for typing in the text box using selenium?

The send Keys are used to enter a string in the text box.

The syntax to add text box in selenium is WebElement Username = drv.findElement(By.id(“Email”));//entering username username.sendkeys(“Sth”)

  1. What are the methods to know the element is displayed on the screen?

The elements to check the visibility in the web driver are isDisplayed(), isSelected(), and isEnabled.

  1. What is the syntax to know the web elements?

IsDisplayed(), IsSelected() and IsEnabled() are the syntax used to know the display or the web elements.

  1. How get command is used in selenium?

Get command is used to retrieve the inner text and to verify the messages labels, and errors etc.

  1. List out the different types of navigation commands in Selenium?

Sample code, navigate().forward(), sample code, navigate().refresh(), sample code, navigate().to(), and sample code are some of the different types of navigation commands in selenium.

  1. What is the difference between the findElement?() and the findelements()?

The difference between the findelement() and findelements() are that both are used for finding the web page matching the specific locator value. Findelement() is used for the first element and findelements() is used for the elements in the web page matching the locator value.

  1. Which class is used to select value in the drop down?

Webdriver’s select class can be used to select the value in the dropdown. The syntax is

SelectbyValue

Select selectByValue = new Selectdriver.findElement(By.id(“SelectID_Two”))));

SelectByVisibleText.selectByVisibleText(“Lime”)

SelectByindex:

Select selectByindex = new Select(driver.findElement(By.id(“SelectID_Three”)))); Join the Selenium Training in Chennai and get in-depth knowledge in to the Automation tools.

SelectByindex.selectByindex(2);

  1. What are the commands for the hyper link and link text in the selenium?

driver.findElement(By.linkText(“Google”)).click();

The link text is used to redirect to the corresponding page. Another command for the link text is

driver.findElement(By.PartialLinkText(“Goo”)).click();  Selenium Training is the best tools for the web based application.

Here the web element finds the substring and then click on it for the partial link text()

  1. How to check a web page with respect to the iframe?

See the advertisement on the page, secondly, right-click the advertisement and check whether the pop-up menu is there, and do the right click on the current web page then select the option from the pop-up menu as view source, type Control+F keys to search for the I frame tags manually. Iframe tags are highlighted with yellow color. Selenium Course in Chennai is the best course for beginners.

  1. How the same type of elements is handled in selenium?

The web elements like hyperlinks and images are arranged in an order or unordered list and handled with same type of code in selenium.

  1. Explain Test script?

The test script is instantiated with the Firefox web driver. The object in the instantiation has reference as ‘driver’. The website URL is https://www.softwaretestingclass.com/ and this helps for the invoke of the driver object. We use the ‘tag Name’ method for the ‘By’ class to locate the I frame tag on the web page. The Firefox diver class returns a list of web elements such as header, footer, and widgets as I frames. The size method is used to count the list of the interfaces in the i frames. These values are printed to the console in the test script. Join the Best Selenium Training in Chennai with industry specific test cases and live projects after the course.

  1. What are the different types of commands in the selenium IDE?

answeronnextpropt, assertchecked, assertalert, assertconfirmation, assertprompt, assertelementpresent, assettext, asserttitile, capturescreenshot, captureentirepagescreenshot, click, clickandwwait, clickat, chooseokonnextconfirmation, csvsave, deleteallcookies, draganddroptoobject, echo, editcontent, highlight, open, mouseover, pause, sourceextract, sourcesearch, refresh, select,selectandwait, selectframe, selectwindow, sendkeys, store, storeattribute, storechecked, storeeval, storetext, storetitle, storevalue, storedvars, throwerror, type, verifyelementpresent, verifytext, verifytitle, waitorelementpresent, waitforelementtoload, waitforpagetoload, and waitforvisible are the different types of commands in the selenium. Join the Best Selenium Training Institute in Chennai to explore more in selenium

  1. Which interface is used to handle the web based pop-ups?

Alert interface is used to handle the web based pop-ups.

  1. What are the four methods in the Alert interface?

Void dismiss, void accept, string gettext(), and void send keys are the four methods in the alert interface. Void dismiss click the cancel button, void accept() method clicks the “ok” button, string getText() returns the displayed on alert box, void sendkeys(string stringTosend) send the specified string pattern in to the alert box.

  1. Define interface in selenium?

Interface is like a blueprint of class. Within the inherit interface the variables and abstract methods are implemented.

  1. How to handle windows based pop up?

Selenium supports only web based testing and it does not support windows based applications. There are so third party tools for the selenium like Auto IT and Robot class.

  1. How to assert tittle of the web page in the selenium?

//verify the title of the web page

AssertTrue(“The tittle of the window is incorrect.,”driver.getTitle?().equals(“Title of the page”));

  1. How to track the activities in the web driver event listener’s interface?

 Type, click, and navigate are activities performed to track the event listeners interface in selenium.

  1. Hot to retrieve the value of CSS properties of an element?

The values of the CSS properties are retrieved with get() method. The syntax for the driver.findElement(By.id(“id”)).getCssValue(“name of css attribute”); driver.findElement(By.id(“id”)).getCssValue(“font-size”); Join the Selenium Training in Chennai to explore different aspects of the selenium.

  1. Write the coding to capture screen shot in the WebDriver?

import org.junit.After;

import org.junit.Before;

import org.junit.Test;

import java.io.File;

import java.io.IOException;

import org.apache.commons.io.FileUtils;

import org.openqa.selenium.OutputType;

import org.openqa.selenium.TakesScreenshot;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver

public class CaptureScreenshot {

WebDriver driver;

@Before

public void setUp() throws Exception {

driver = new FirefoxDriver();

driver.get(“https://google.com”);

}

@After

public void tearDown() throws Exception {

driver.quit();

}

@Test

public void test() throws IOException {

// Code to capture the screenshot

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

// Code to copy the screenshot in the desired location

FileUtils.copyFile(scrFile, new File(“C:\\CaptureScreenshot\\google.jpg”))

}

}

  1. Who introduced J unit to java?

J Unit is introduced by Apache and it is a unit testing framework. J Unit is based on java.

  1. List the Junit annotations?

The JUnit annotations are @Test, @Before, @After, @beforeclass, @afterclass, and @ignore.

  1. Explain the different Junit annotation?

@Test is for the method, @Before is for the execution of method every time after test, @After method is executed after the test method, @BeforeClass is used to execute before any test methods, @Afterclass is executed after any of the test methods, @ignore method is used for not executing the method.

  1. What are the advantages of the Test NG over the J Unit?

Added advance and annotations are easy, it is easy to set the execution patterns, concurrent execution of test scripts, and the dependencies for the test case can be set for the J Unit.

  1. How to implement the listeners in selenium web driver script?

The first step is to create a class in the event capture, second step is to create another class called the “listenermainclass” to write a script, third step is to pass driver object as a parameter and create eventfiringwebdriver object.

  1. Explain the terms related to the test automation framework?

The framework is the combination of the programming language used, type of framework used, the class in the test base, to separate the element locators and tests, utility functions file, property files, testNG annotations, parameterization using excel files, errors are captured with the screenshots, the reports are generated, the reports are emailed, use the system of the version control, and continue the integration tool used.

  1. List out the advantages of automation framework?

The advantages of test automation framework are reusability of code, coverage to the maximum, recovery scenario, low-cost maintenance, minimal manual intervention and easy reporting.

  1. What are the two packages in the selenium?

The two packages in the selenium are the page related classes and test related classes.

  1. Explain in detail about the different types of the frameworks?

Module based testing framework divide the application and each module is created with a separate and independent test script. The library architecture testing framework is to group the functions, data driven testing framework is to   segregate the test script logic and test data, keyword driven testing framework segregates the test data from the scripts, hybrid testing framework is the combination of framework and it gives the benefit of all kinds of the associated frameworks.

  1. If the test data is in the excel then how is it read?

Test data can be read with the excel using JXL, POI or API.

  1. List out the difference between POI and JXI jar?

JXL supports “XLS” format and POI jar supports all the formats, JXL API is updated periodically and the last update is by 2009, POI is regularly updated, the JXL documentation is not comprehensive and POI is well prepared and highly comprehensive, Rich format is possible with POI and not possible with JXL API, JXL API is faster than the POI API.

  1. List out the difference between selenium and QTP?

Browser compatability, distribution, Application under test, object repository, language support, and vendor support are some of the differences between selenium and qtp.

  1. IS it possible to test the mobile application with selenium?

It is not possible to test the mobile application with selenium because it is for web based tool and applications on the mobile browser can be tested.

  1. Is it possible to automate the captcha?

No, it is not possible to automate the captcha.

  1. How to create the object repository in selenium?

The productlisting_page is created under the page objects, name the pageobjects as product_1, for the child element in the webpage create static method and these methods will have a argument and a return value, to see all the products in the class type the productlisting_page in your test script.

  1. Is it possible to store the objects in the excel sheet?

Yes, it is possible to store the objects in the excel sheet.

The above provided selenium interview questions are prepared with an intension to help the aspirants before attending the interview. The practical oriented training, real time projects and the interview questions makes the Selenium Training tailored to the individual needs of the students.

Comments are closed.