Sunday, October 31, 2021

ITC Infotech Interview Question for Automation Test engineer (2 to 5 year Experience 2021)

 1) Tell me about skills, roles , responsibilities and experience ?

2) What Singleton class in java can you write code ?

3) WAP to count each occurrence of words in Sentence ?

4) What is steal Element exception in selenium ?

5) What is finally block in java ?

6) What is hooks in cucumber ?

7) What is difference between selenium and cucumber ?

8) Can you explain your Rest assured framework ?

9) How to authenticate POST method ?

10) What is Hash Map and Hash Tree ?

11) where you have used collection in your project ?

DBS Interview Question for Automation Test engineer (2 to 5 year Experience 2021)

 1) Tell me About your roles and responsibilities in your current projects. 

2) What is interface and abstract class 

3) How to handle Alert 

4) Write code for Screenshot . 

5) write a code to find duplicate in Array and display each  occurrence . 

6) What is difference between close  and quit method

7) Can you tell 5 exception in selenium. 

8) Write queries for max sal 5 salary for emp

9) Can you explain your framework

10) How create jobs in Jenkins

11) How to schedule job in Jenkins


ADP Interview Question for Automation Test engineer (2 to 5 year Experience 2021)

 1) Tell me about your self

2) What is locator and types of locations

3) Given to write Xpath using I'd locator 

4) WAP to find duplicate character in String. 

5) What is overriding and overloading in java and WAP for overriding and overloading. 

6) What is wait statements in selenium? 

7) Have you developed framework. 

8) What is method hiding

9) WAP to reverse each character in string.

Genpact Interview Question for Automation Test engineer (2 to 5 year Experience 2021)

 1)Tell Me about your self

2) WAP to reverse String

3) WAP to reverse each world in String.

4) WAP to reverse sentence

5) WAP to count each Occurrence of String

6) What is constructor

7) What is static member in java

8) What is overriding and rules of overriding

9) What is private keyword.

10) What is Singleton pattern

11) What is an  Interface and how many types of Interface is available in collection.

12) What hard Assert and Soft assert in selenium

13) How to handle multiple window in selenium

14) How to handle frame in selenium

15) What is Wait statement in selenium

16) How many types of exception is there in selenium.

17) What is System. Out.Println()

18) What is Authorization and Authentication


UST Global Interview Question for Automation Test engineer (2 to 5 year Experience 2021)

1)Tell me about your roles and responsibilities in your current project. 

2) Which framework you have used. Can you explain. 

3) Which built tools do u have used and explain maven life cycle. 

Ans:- 

 mvn clean: Cleans the project and removes all files generated by the previous build.

 mvn compile: Compiles source code of the project.

 mvn test-compile: Compiles the test source code.

 mvn test: Runs tests for the project.

 mvn package: Creates JAR or WAR file for the project to convert it into a distributable format.

 mvn install: Deploys the packaged JAR/ WAR file to the local repository.

 mvn deploy: Copies the packaged JAR/ WAR file to the remote repository after compiling, running tests and building the project. 4) Have you used Git. What conflict and how to resolve. 

Ans;- A merge conflict is an event that takes place when Git is unable to automatically resolve differences in code between two commits. Git can merge the changes automatically only if the commits are on different lines or branches.

       https://stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-a-git-repository

5) What is Head command. 

Ans:- The term HEAD refers to the current commit you are viewing.

6) What is POM & What is page factory. 

7) What is the difference between Absolute Xpath and Relative Xpath. 

8)What is Fluent Wait? 

9) What is javaScriptExecuter ?

10) How to enter value in text fields without Sendkeys 

Ans:- driver.get("http://www.qajudge.com/"); WebElement cssValue= driver.findElement(By.xpath(".//*[@id='s']")); JavascriptExecutor jse = (JavascriptExecutor) driver; jse.executeScript("document.getElementById('s').value='Virender Testing sending'");

https://stackoverflow.com/questions/26955263/is-there-any-other-waynot-sendkeys-to-enter-text-into-textbox-using-selenium-w

11) What is default the constructor and parameterize constructor. 

12) WAP to find duplicate char in String. 

13) Why java is not purely oop. 

Thursday, October 7, 2021

RestAssured Examples

 package RestAssuredNews.RestAssuredNewApp;

import org.testng.Assert;


import org.testng.annotations.Test;


import io.restassured.config.LogConfig;

import io.restassured.http.Header;

import io.restassured.http.Headers;

import io.restassured.path.json.JsonPath;

import io.restassured.response.Response;


import static io.restassured.RestAssured.*;

import static io.restassured.matcher.RestAssuredMatchers.*;

import static org.hamcrest.Matchers.*;


import java.util.Collections;

import java.util.HashMap;

import java.util.HashSet;

import java.util.List;

import java.util.Set;


import static org.hamcrest.MatcherAssert.assertThat;


public class GetAutomationTest {

public void testjava(){

}

@Test(enabled=false)

public void valiateStatusCode(){

given().

      baseUri("https://api.postman.com")

      .header("x-api-key","PMAK-606a8c2da5c08a004dfd060f-c7cdd622c690177cce465538021e349288").

when().

     get("/workspaces").

then()

.log().all()

.assertThat()

.statusCode(200);

}

@Test(enabled=false)

public void validate_response_body(){

given().baseUri("https://api.postman.com")

.header("x-api-key", "PMAK-606a8c2da5c08a004dfd060f-c7cdd622c690177cce465538021e349288")

.when().get("/workspaces")

.then().log().all()

.assertThat().statusCode(200)

.body("workspaces.name",hasItems("APITesting","MyMockServer","My Workspace2","Team Workspace",

"myworkspace")

,"workspaces.type",hasItems("team","team","team","team"),

"workspaces[0].name",equalTo("APITesting")

,"workspaces[0].name",is(equalTo("APITesting"))

,"workspaces.size()",equalTo(5)

,"workspaces.name",hasItem("APITesting"));

}

   @Test(enabled=false)

   public void extract_response(){

  Response res= given().baseUri("https://api.postman.com")

   .header("x-api-key", "PMAK-606a8c2da5c08a004dfd060f-c7cdd622c690177cce465538021e349288")

   .when()

    .get("/workspaces")

    .then()

    .assertThat()

    .statusCode(200)

    .extract().response();

  System.out.println("Response = " + res.asString());

   }

   

   @Test(enabled=false)

   public void extract_single_value_from_response(){

String name=  given().baseUri("https://api.postman.com")

   .header("x-api-key", "PMAK-606a8c2da5c08a004dfd060f-c7cdd622c690177cce465538021e349288")

   .when()

    .get("/workspaces")

    .then().assertThat()

    .statusCode(200)

    .extract()

    .response().path("workspaces[0].name");

System.out.println("workspace name = " + name);

// JsonPath.from(res).getString("workspaces[0].name");

//System.out.println("workspace name = " + JsonPath.from(res).getString("workspaces[0].name"));

 

 

   //System.out.println("workspace name = " + res.path("workspaces[0].name"));

//JsonPath js=new JsonPath(res.asString());

// System.out.println("workspace name = " + js.getString("workspaces[0].name"));

 

   }

   

   @Test(enabled=false)

   public void hamcrest_assert_on_extracted_response(){

   String name =given().baseUri("https://api.postman.com")

   .header("x-api-key", "PMAK-606a8c2da5c08a004dfd060f-c7cdd622c690177cce465538021e349288")

   .when()

    .get("/workspaces")

    .then()

    .assertThat()

    .statusCode(200)

    .extract()

    .response().path("workspaces[0].name");

 

   System.out.println("workspace name=" + name);

  // assertThat(name,equalTo("APITesting"));

   Assert.assertEquals(name, "APITesting");

   

   }

   

   @Test(enabled=false)

   public void validate_response_body_hamcrest_learning(){

   given()

   .baseUri("https://api.postman.com")

   .header("x-api-key", "PMAK-606a8c2da5c08a004dfd060f-c7cdd622c690177cce465538021e349288")

   .when()

    .get("/workspaces")

    .then()

    .assertThat()

    .statusCode(200)

    .body("workspaces.name",contains("APITesting","MyMockServer","My Workspace2",

    "Team Workspace","myworkspace"),"workspaces.name",is(not(emptyArray()))

    ,"workspaces.name",hasSize(5)

    //,"workspaces.name",everyItem(startsWith("My"))

   

    ,"workspaces[0]",hasKey("id")

    ,"workspaces[0]",hasValue("APITesting")

    ,"workspaces[0]",hasEntry("id","1f44f446-31d0-429e-8e92-ed6fdb17934b")

    ,"workspaces[0]",not(equalTo(Collections.EMPTY_MAP))

    ,"workspaces[0].name",allOf(startsWith("API"),containsString("Testing")));

   

   }

   

   @Test(enabled=false)

   public void request_response_logging(){

   given()

    .baseUri("https://api.postman.com")

    .header("x-api-key", "PMAK-606a8c2da5c08a004dfd060f-c7cdd622c690177cce465538021e349288")

    .config(config.logConfig(LogConfig.logConfig().enableLoggingOfRequestAndResponseIfValidationFails()))

    //.log().ifValidationFails()

        .when()

        .get("/workspaces")

        .then()

        //log().ifValidationFails().

        .assertThat()

        .statusCode(201);

   

   }

   

   @Test(enabled=false)

   public void log_blacklist_header(){

   Set<String> headers=new HashSet<String>();

   headers.add("x-api-key");

   headers.add("Accept");

   given()

    .baseUri("https://api.postman.com")

    .header("x-api-key", "PMAK-606a8c2da5c08a004dfd060f-c7cdd622c690177cce465538021e349288")

    .config(config.logConfig(LogConfig.logConfig().blacklistHeaders(headers)))

    .log().all()

    .when()

    .get("/workspaces")

    .then()

    .assertThat()

    .statusCode(200);

   }

   

   @Test(enabled=false)

   public void multiple_headers(){

   HashMap<String,String> headers=new HashMap<String,String>();

   headers.put("header", "value1");

   headers.put("x-mock-match-request-headers", "header");

   given()

    .baseUri("https://5e6acb5c-eb77-40a9-ac40-7dfc335f8288.mock.pstmn.io").

   // headers(headers).

    header("multiValueHeader","value1","value2").

    log().headers().

   when() 

    .get("/get")

    .then()

        .log().all()

        .assertThat()

        .statusCode(200);

  }

   

   

   @Test(enabled=false)

   public void multi_value_in_the_request(){

   Header header1=new Header("multiValueHeader","value1");

   Header header2=new Header("multiValueHeader","value2");

   

   Headers headers=new Headers(header1,header2);

   

   given().

    baseUri("https://5e6acb5c-eb77-40a9-ac40-7dfc335f8288.mock.pstmn.io")

    .headers(headers)

    .log().headers().

   when().

    get("/get")

    .then()

    .log()

    .all()

    .assertThat()

    .statusCode(200);

      } 

   

   @Test(enabled=false)

   public void asser_response_headers(){

   HashMap<String,String> headers=new HashMap<String,String>();

   headers.put("header","value1");

   headers.put("x-mock-match-request-headers","header");

   given()

    .baseUri("https://5e6acb5c-eb77-40a9-ac40-7dfc335f8288.mock.pstmn.io").

    headers(headers).

   

    when()

    .get("/get").

    then().

    log().all().

    assertThat()

    .statusCode(200).

    //header("responseHeader","resValue1").

            //header("X-RateLimit-Limit","120");

    headers("responseHeader","resValue1","X-RateLimit-Limit","120");

   }  




  @Test(enabled=false)

  public void extract_response_headers(){

  HashMap<String,String> headers=new HashMap<String,String>();

  headers.put("header","value1");

   headers.put("x-mock-match-request-headers","header");

   Headers extractedheaders=given()

    .baseUri("https://5e6acb5c-eb77-40a9-ac40-7dfc335f8288.mock.pstmn.io").

    headers(headers).

    when().get("/get").

    then().

    log().all()

    .assertThat()

    .statusCode(200)

    .extract()

    .headers();

   for(Header header:extractedheaders){

   System.out.println("header name = " + header.getName() + " ,");

   System.out.println("header value = " + header.getValue());

   }

/*

System.out.println("header name = " + extractedheaders.get("responseHeader").getName());

System.out.println("header value = " + extractedheaders.get("responseHeader").getValue());

System.out.println("header value = " + extractedheaders.getValue("responseHeader"));

*/

  }

  

  @Test

  public void extract_multivalue_response_header(){

  HashMap<String,String> headers=new HashMap<String,String>();

  headers.put("header","value1");

   headers.put("x-mock-match-request-headers","header");

   Headers extractedheaders=given()

    .baseUri("https://5e6acb5c-eb77-40a9-ac40-7dfc335f8288.mock.pstmn.io").

    headers(headers).

    when().get("/get").

    then().

    //log().all()

    assertThat()

    .statusCode(200)

    .extract()

    .headers();

   List<String> values=extractedheaders.getValues("multiValueHeader");

   for(String value:values){

   System.out.println(value);

   }    }}

 


 

   

   


Q) How To Find Duplicate Characters In A String In Java?

Step1:- Creating a HashMap containing char as key and it's occurrences as value. Step2:- Converting given string to char array. Step3:- ...