Tuesday 17 August 2021

Commonly asked selenium interview questions - Part 1




Commonly asked selenium interview questions I will keep updating the list.

I have added the answer along with the questions but feel free to comment below if you feel there are any better answers or there can be more questions that can be added.

 

1.     Write xpath using contains keyword : //h3[contains(text(),'Health Testing')]

 

  1. Difference between Interface and abstract class: 

In Java, abstraction is achieved using Abstract classes and interfaces. Both contain abstract methods which a child class or implementing class has to implement. Following are the important differences between abstract class and an interface. An abstract class permits you to make a functionality that subclasses can implement or override whereas an interface only permits you to state functionality but not to implement it. A class can extend only one abstract class while a class can implement multiple interfaces.

  1. Which one follows 100% abstraction: 

Interfaces

 

  1. What are the different types of collections used? 

Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet).

 

  1. String abc = "My name is saif" find saif

// Java program to demonstrate working

// contains() method

class Gfg {

 

// Driver code

public static void main(String args[])

{

String s1 = "My name is GFG";

 

// prints true

System.out.println(s1.contains("GFG"));

 

// prints false

System.out.println(s1.contains("geeks"));

}

}

 

  1. Difference between implicit and explicit wait: 

Implicit waits are used to provide a default waiting time between each consecutive test step/command across the entire test script. ... Explicit waits are used to halt the execution until the time a particular condition is met or the maximum time has elapsed.

 

  1. Different desired capabilities in Selenium?    getBrowserName():,setBrowserName(),getVersion(),setBrowserName()

 

  1. How to use extent report:      

ExtentReports is an open-source reporting library useful for test automation. It can be easily integrated with major testing frameworks like JUnit, NUnit, TestNG, etc. These reports are HTML documents that depict results as pie charts. They also allow the generation of custom logs, snapshots, and other customized details. Once an automated test script runs successfully, testers need to generate a test execution report. While TestNG does provide a default report, they do not provide the details

 

  1. Why we use listeners :

As the name suggests, Listeners possess the ability to “listen” to a certain event. Often used for customizing reports and logs, it serves as an interface that can modify system behavior.

 

  1. @BeforeTest vs @BeforeMethod

@BeforeTest: It will call Only once, before Test method. @BeforeMethod It will call Every time before Test Method.

 

  1. We have two class in each class we have two test annotations how many times before test and after test run will run and how many times before and after method will work.

            Before Test and after test two time and before method and after method test     4 times

 

  1. If the priority is not set for test how it will run?

If you don’t mention the priority, it will take as “priority=0” for all the test cases and execute. Lower priorities will be executed first. If we define priority as “priority=” for multiple test cases, then these test cases will get executed only after all the test cases which don’t have any priority and set priority to 0 as the default priority

 

  1. Tell me something about yourself, your current company, and current project?

            Answer here: https://youtu.be/roxO0X_k9EU

14.  Explain the different exceptions in Selenium WebDriver,chrome,firefox,iOs driver android driver: Though there are many Exception classes under WebDriverException, we commonly see the below ones;

·       NoSuchElementException

·       NoSuchWindowException

·       NoSuchFrameException

·       NoAlertPresentException

·       InvalidSelectorException

·       ElementNotVisibleException

·       ElementNotSelectableException

·       TimeoutException

·       NoSuchSessionException

·       StaleElementReferenceException

 

 

  1. What is a page object?

Page Object is a Design Pattern that has become popular in test automation for enhancing test maintenance and reducing code duplication. A page object is an object-oriented class that serves as an interface to a page of your AUT.

 

  1. How to scroll down a page using JavaScript in Selenium?

jse.executeScript("scroll(0, 250);");

We can scroll down a page by using window.scrollBy() function.

 

16.  Dependsonmethod: dependsOnMethods : 

dependsOnMethods attribute on a test method [test1 e.g.] specifies all the test methods [test2, test3,..] this test method depends on. It means test1 will start execution only after all the tests it depends on executed successfully.

 

  1. Synchronization technique: 

all waits

  1. What type of reports you have worked on

The above classes can be used with the frequently used built-in methods that are stated below.

·       startTest

·       endTest

·       Log

·       flush

startTest and endTest methods are used to execute preconditions and post-conditions of a test case, while log method is used to log the status of each test step onto the resultant HTML report. Flush method is used to erase any previous data on the report and create a new report.

Test Status can be any of the following values:

·       PASS

·       FAIL

·       SKIP

·       INFO

Syntax:

reports.endTest();

test.log(LogStatus.PASS,”Test Passed”);

test.log(LogStatus.FAIL,”Test Failed”);

test.log(LogStatus.SKIP,”Test Skipped”);

test.log(LogStatus.INFO,”Test Info”);

 

  1. Write a program to reverser string

// Java praogram to illustrate the

// java.lang.StringBuffer.reverse()

import java.lang.*;

 

public class Test {

 

public static void main(String args[])

{

StringBuffer sbf = new StringBuffer("Geeksforgeeks!");

System.out.println("String buffer = " + sbf);

 

// Here it reverses the string buffer

sbf.reverse();

System.out.println("String buffer after reversing = " + sbf);

}

}

 

19 - create xpath find element before any element?


20 - run same test cases multiple time

            TestNg has one method.

            @Test(invocationCount = 100)

 

 

 Here is the Appium Playlist for beginners:  Appium


 

 

 

 

No comments:

Post a Comment

Interview Experience with AMAZON for the role of Quality Assurance Tester

This role was for Digital/ IoT/Mobile Application based testing :)  Amazon is a dream company and everyone wants to work for that company a...

Popular Posts