Pages

Wednesday, 20 May 2020

Top 15 Selenium Interview question for QAE/Automation Testing/SDET?





Check Selenium-SDET-UIAutomation Questions set 21 to 30:
 
Check Selenium-SDET-UIAutomation Questions set 31 to 40:

 Question Set 31-40  

Check Selenium-SDET-UIAutomation Questions set 41-50:

Q&A Set 41-50

To check API related topics and interview tips check below and keep reading:

Most Asked API Question For SDET


Before we start looking into the interview questions and answers let’s understand quickly about Selenium along with the reasons behind the popularity of the same. The most important fact about Selenium is that it has the highest market share in any of the automation solutions available in the market for web automation, and with that fact let’s start our interview preparation with Selenium questions and answers.


What is Selenium?


Selenium is an open source umbrella project for a range of tools and libraries aimed at supporting browser automation. It provides a playback tool for authoring functional tests across most modern web browsers, without the need to learn a test scripting language.


Why do we need Selenium?

Most programmers and developers who build website applications and wish to test them every now and then use Selenium. One of the biggest advantages of Selenium, which has made it so popular, is its flexibility. Any individual who creates web programs can use Selenium to test the code and applications. Further, professionals can debug and perform visual regression tests as per the requirements of the website or code.

In most organisations, it is the job of quality analyst (QA) engineers to test web applications by using Selenium. They are required to write scripts that can help in maximising accuracy and test coverage to make changes in the project and maintain the infrastructure of the test.



1. How to perform back,forward and refresh actions in selenium?
  • driver.navigate().back()
  • driver.navigate().forward()
  • driver.navigate().refresh()

2. What is the return type of findelements?

List of elements with similar property

3. Explain some of the strategies you have followed while using xpath?

Click here for answer


4. What will happen if no webelement is found for findelements?


It will return an empty list

5. What will happen if no webelement is found for findelement?

It will give error as :NoSuchElementException


 6. How to switch frames in selenium?



7. How to select value from dropdown in selenium?

Using select class as below
Select technology = new Select(driver.findElement(By.xpath("//select[@id='effectTypes']")));
technology.selectByVisibleText("Drop");


8. What are the methods provided in selenium to select from dropdown?

  •     selectByVisibleText()
  •     selectByValue()
  •     selectByIndex()
   
9. How to fetch text from UI in selenium?
  • gettext()
  • getAttribute("propertyname")

10. Explain some of the strategies to handle CAPTCHA?


11. How to get current url,title and page source?

  • driver.getCurrentUrl();
  • driver.getTitle();
  • driver.getPageSource();

12. How to clear text using selenium?

clear() — method is used to clear text from the text area
driver.findElement(By.xpath(“//input[@placeholder=’Username’]”)).clear();

13. How to do Browser Initialization for all types of browsers?

•    Firefox
WebDriver driver = new FirefoxDriver();
•    Chrome
WebDriver driver = new ChromeDriver();
•    Internet Explorer
WebDriver driver = new InternetExplorerDriver();
•    Safari Driver
WebDriver driver = new SafariDriver();

14. What is page load strategy in Selenium?

Click Here For Answer


REVISION:


28. How to get all cookies and with name of the cookie?

driver.manage().getCookies();
driver.manage().getCookieNamed("APISID");

29. How to delete all cookies and with name of the cookie?

driver.manage().deleteCookieNamed("APISID");
driver.manage().deleteAllCookies();

30. How to add a cookie?

 Cookie cookie1 = new Cookie("test2", "cookie2");
 driver.manage().addCookie(cookie1);


*************************************** TOP 15 BDD - CUCUMBER Interview Q&A

************************************************

✍️AUTHORLinkedIn Profile

************************************************

Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

For more details whatsapp: https://lnkd.in/dnBWDM33

*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

API Testing Interview Question Set:

https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

DevOps Interview Q&A:

https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

Kubernetes Interview Question Set

https://automationreinvented.blogspot.com/search/label/Kubernetes

Docker Interview Question Set

https://automationreinvented.blogspot.com/Docker

Linux Interview question Set

https://automationreinvented.blogspot.com/search/label/Linux

Automation Testing/SDET Framework Design

https://automationreinvented.blogspot.com/search/label/FrameworkDesign

Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java

GIT Interview Question Set:

https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

Coding Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Mobile Testing Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

Python Interview Question Set for QAE - SDET - SDE:

https://automationreinvented.blogspot.com/search/label/Python


 


Monday, 18 May 2020

How to log automation execution status to Extent Report? Write the code for Extent Report log execution status? SDET



Details of the methods and class used in the code:

  • public = access modifier
  • void= will not return anything
  • ITestResultorg.testng.ITestResult and it describes result of test
  • getStatus()=to fetch the execution status of test case
  • ExtentReport.extentlog.log=Logs events for the test
  • ExtentReport.extentreport.endTest= Ends and prepares the test to be added to the report on flush()
****************CODE START*********************

public void getResult(ITestResult result) {

        if (result.getStatus() == ITestResult.SUCCESS) {

            ExtentReport.extentlog.log(LogStatus.PASS, "Test case is passed "+ "Test" );

        } else if (result.getStatus() == ITestResult.FAILURE) {
            ExtentReport.extentlog.log(LogStatus.FAIL, "Test case is failed " );
            ExtentReport.extentlog.log(LogStatus.FAIL, "Test case is failed " + result.getThrowable());
        } else if (result.getStatus() == ITestResult.SKIP) {
            ExtentReport.extentlog.log(LogStatus.SKIP, "Test case is Skiped " + result.getName());
        }
        ExtentReport.extentreport.endTest(ExtentReport.extentlog);
    }

***************************CODE END********
Note: If anyone need help in designing framework or virtual support for Automation work then reach out to me @sidharth.shukla19@gmail.com/9619094122
***********************************
For training check the Training link as below:
Training Details
More content for Interview preparation:RestAPI
SQL Query   Cucumber-BDD    Linux Commands    Maven   GIT 

TestNG@after@before
 

*************************************************



Learn (API-Microservice)Testing+(CoreJava+UI)-SDET with Self Paced Videos and one LIVE Doubt Session

TRANING VIDEOS AVAILABLE with Live Doubt Session @4500/-(course-1 below,API TRaining Videos With ClassNotes and Coding Set) and 6500/- (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122

Entire course content can be found below:  COURSE CONTENTCheck below link for question and answers with code:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Sunday, 17 May 2020

How to read properties file and fetch data? Write code to read common.properties file?


  • In below code filepath parameter will contain the path where we will keep the properties file and key parameter is the name of the value which we want fetch.
  • public is the access modifier
  • static  so that we can access the class without creating object
  • String is the return type of propertyReader function

============================
public static String propertyReader(String filePath,String key)

{
        String value = null;
       
        //Inputstream is required while loading into properties
   
       try (InputStream input = new FileInputStream(filePath))
        {
           
           // object creation for Property class
            Properties prop = new Properties();

            // load a properties file
            prop.load(input);

            //getProperty will fetch the value according to the key
            value=prop.getProperty(key);
         

        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return value;
       
    }


Want to learn more about Framework Design, do check out below link :



 

************************************************* 

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design 
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions

***********************************
Note: If anyone need help in designing framework or virtual support for Automation work then reach out to me @sidharth.shukla19@gmail.com/9619094122
***********************************
For training check the Training link as below:
Training Details
More content for Interview preparation:
How to add execution status to Extent Report

Friday, 15 May 2020

Automate GET request with Rest Assured? API Automation interview question on Rest Assured?



Requirement:
- Automate GET api for endpoint: /api/users and validate status code as 200

=================CodeStart================
@Test

        //public is access modifier and void as nothing is returned for getusers()

        public void getusers()
   
        {
           
            // resp will contain the response from the api get method for /api/users?page=2
       
            Response resp = given()
                    .when().get("serverURL/api/users?page=2");
           
            //save the actual status code in integer variable, variable name is actualstatuscode

            int actualstatuscode = resp.getStatusCode();
           
            //print the status code in the console
            System.out.println(resp.getStatusCode());

           //print the response body in console
            System.out.println(resp.getBody().asString());
           
            //validating actual status code that we got from API response with the expected status code 200
            assertEquals(200,actualstatuscode);
           
        }

===============CodeEnd================
Note :
Import below in your package before using the code and add rest assured/testng jar:
import static io.restassured.RestAssured.given;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
import io.restassured.response.Response;
====================================
Note: If anyone need help in designing framework or virtual support for Automation work then reach out to me @sidharth.shukla19@gmail.com/9619094122 
**************************************
For training check the Training link as below:
Training Details
Check below link on top Interview preparation topics:RestAPI
SQL Query   Cucumber-BDD    Linux Commands    Maven   GIT 

TestNG@after@before
 

*************************************************

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions



Wednesday, 6 May 2020

How to extract data from JSON file in Java? Automation/SDET interview question to parse JSON?




Java Interview question Set-1:
SET-01 1-10

Java Interview question Set-2:

SET-02 10-20

Java Interview question Set-3:

SET-03 21-30


Data driven testing for Selenium and Rest Assured with Json file

Learn how to extract data from a JSON file in Java, we will discuss two ways, but any method can be used in your framework, Remember to add it to Utility.
This will help us to perform Data driven testing for Selenium and Rest Assured with Json file.

There are two ways we can fetch data from the JSON file:
- using jsonobject
- using jsonpath

Let's discuss both the approaches.

How to fetch test data from json file using jsonobject

1. Create a testdata.json file


2. Create a method which will fetch value from json object using key


public static String getTestData(String input) throws IOException, ParseException {
        String testdata;
        return testdata = (String) getJsonData().get(input);//input is the key
       
    }
   

3. Create a method as  getJsonData() with return type as JsonObject


public static JSONObject getJsonData() throws IOException, ParseException  {
       
        //pass the path of the testdata.json file
        File filename = new File("TestData//testdata.json");
        //convert json file into string
        String json = FileUtils.readFileToString(filename, "UTF-8");
        //parse the string into object
        Object obj = new JSONParser().parse(json);
        //give jsonobject o that I can return it to the function everytime it get called
        JSONObject jsonObject = (JSONObject) obj;
        return jsonObject;

    }
To learn more about JSON please refer below link:



How to fetch test data from json file using jsonPath?

    Note: Use https://jsonpath.com/ to write your own jsonpath

    1. Create a testdata.json file


    2. Create a method which will fetch value from json object using key


public static String getdatafromjson(String path) throws IOException {
       
        File f = new File("TestData//testdata.json");
        String json = FileUtils.readFileToString(f, "UTF-8");
        String result;
        return result = JsonPath.read(json, path);
       
    }

There is one more way to do the same which is by using the POJO class, check the post below for all the steps in json to pojo conversion:





Want to learn more about Framework Design, do check out the link below for configuration properties and extent reporting:



Java Interview question Set-1:
SET-01 1-10

Java Interview question Set-2:

SET-02 10-20

Java Interview question Set-3:

SET-03 21-30


Learn (API-Microservice)Testing+(CoreJava+UI)-SDET with Self Paced Videos and one LIVE Doubt Session

TRANING VIDEOS AVAILABLE with Live Doubt Session @4500/-(course-1 below,API TRaining Videos With ClassNotes and Coding Set) and 6500/- (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122
Entire course content can be found below:  COURSE CONTENT

***********************************
Note: If anyone need help in designing framework or virtual support for Automation work then reach out to me @sidharth.shukla19@gmail.com/9619094122
***********************************



*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions
Mobile Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

Python Interview Question Set for QAE - SDET - SDE:
https://automationreinvented.blogspot.com/search/label/Python