Debomita Bhattacharjee

Debomita Bhattacharjee

590 Articles Published

Articles by Debomita Bhattacharjee

Page 3 of 59

Explain how to get the size of a JSON array response in Rest Assured.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 22-Nov-2021 3K+ Views

We can get the size of a JSON array response in Rest Assured. First, we shall obtain a Response body which is in JSON format from a request. Then convert it to string. Finally, obtain its length with the size method. Code Implementationimport static io.restassured.RestAssured.given; import org.testng.annotations.Test; import io.restassured.RestAssured; import io.restassured.path.json.JsonPath; import io.restassured.response.Response; public class NewTest {    @Test    public void jsonAryLen() {       //obtain Response from GET request       Response res = given()       .when()       .get("https://jsonplaceholder.typicode.com/posts");       //convert JSON to string       JsonPath ...

Read More

How to create a Feature file for Cucumber in Java?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 22-Nov-2021 5K+ Views

We can create a Feature file for Cucumber. This can be done using the below steps−Step1− Click on the File menu in Eclipse. Then select the option New. Next click on OtherStep2− Click on Maven Project from the Maven folder. Then click on Next.Step3− Proceed with the further steps.Step4− Select maven-archetype-quickstart template. Then click on Next.Step5− Add GroupId as Automation, Artifact Id as Cucumber, and proceed.Step6− A project should get created with a Cucumber-type project structure. The Cucumber-related scripts should be written within the src/test/java folder.Step6− Create a new package called features inside the src/test/java folder.Step7− Create a feature file ...

Read More

How to add Cucumber Maven dependencies to the project?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 22-Nov-2021 4K+ Views

We can add Cucumber Maven dependencies to a project. This can be done by following the below steps −Step1− Create a Maven project. The details on how to create a Maven project is discussed in detail in the below link −https://www.tutorialspoint.com/maven/index.htmStep2− Add the following dependencies in the pom.xml file in a project for Cucumber.Cucumber JVM - Java dependencyhttps://mvnrepository.com/artifact/io.cucumber/cucumber-javaCucumber JVM - JUnit dependencyhttps://mvnrepository.com/artifact/io.cucumber/cucumber-junitStep3− Click on the Project menu, then select the option Build Automatically.Step4− Click on the Maven Dependencies folder within the project. All the Cucumber-related dependencies which we have obtained via Maven should be visible.

Read More

How to get a value from a nested list in Rest Assured?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 22-Nov-2021 3K+ Views

We can get a value from a nested list in Rest Assured. This is done with the help of the extract method. To grab the item, we have to use the path method(after the extract method) and pass the item in the response we want to obtain.We shall first send a GET request via Postman on a mock API URL and go through its Response having a nested list.ExampleCode Implementationimport org.testng.annotations.Test; import static io.restassured.RestAssured.given; import java.util.ArrayList; import io.restassured.RestAssured; import io.restassured.http.ContentType; public class NewTest {    @Test    public void getRequest() {       //base URL       ...

Read More

Explain how to extract value using JSONPath.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 22-Nov-2021 4K+ Views

We can use JsonPath in Rest Assured to extract value. This is done with the help of the jsonPath method (which is a part of the JsonPath class). After that, we need to use the get method and pass the key that we want to obtain from the JSON Response.We shall first send a GET request via Postman on an endpoint and observe the JSON response. Here, the keys are userId, id, title, and body.ExampleCode Implementationimport org.testng.annotations.Test; import static io.restassured.RestAssured.*; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.path.json.JsonPath; import io.restassured.response.Response; public class NewTest {    @Test    void getValueJsonPath() {   ...

Read More

How to use the then method in Rest Assured?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 22-Nov-2021 2K+ Views

We can use the then method in Rest Assured. It is mainly used to validate a Response obtained from a request. Thus, most assertions are included within a then method.SyntaxRestAssured.baseURI = "http://dummy.restapiexample.com"; //GET operation with then methods given() .when().get("/api/v1/employees").then() //verify status code as 404 .assertThat().statusCode(404);ExampleCode Implementationimport org.testng.annotations.Test; import static io.restassured.RestAssured.*; import io.restassured.RestAssured; public class NewTest {    @Test    void test() {       //base URL       RestAssured.baseURI =       "http://dummy.restapiexample.com";       //input details for GET request       given()       .when().get("/api/v1/employee/1")       ...

Read More

How to create a Cucumber project template using Maven in Eclipse?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 22-Nov-2021 3K+ Views

We can create a Cucumber project template using Maven. This can be done by following the below steps −Step1− Click on the File menu in Eclipse. Then select the option New. Next click on Other.Step2− Click on Maven Project from the Maven folder. Then click on Next.Step3− Proceed with the further steps.Step4− Select maven-archetype-quickstart template. Then click on Next.Step5− Add GroupId as Automation, Artifact Id as Cucumber, and proceed.Step6− A project should get created with a Cucumber-type project structure. The Cucumber-related scripts should be written within the src/test/java folder.

Read More

Which Eclipse Plugin should be installed to work with Cucumber?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 22-Nov-2021 953 Views

We need to install the Natural plugin in Eclipse to work with Cucumber. To install it follow the below steps −Step 1 − Click on the Help menu in Eclipse, then select Eclipse MarketplaceStep2 − Enter Natural in the Find field and click on Go. Then click on Install.Step 3 − Proceed with the installation process.Step 4 − After installation is completed, click on the Restart Now button to restart Eclipse again.Step 5 − Again launch Eclipse, then click on the Help menu, then select Eclipse Marketplace. Enter Natural in the Find field and click on Go. Now, the Natural plugin shall be shown as ...

Read More

What is a Pytest framework?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 19-Nov-2021 755 Views

Pytest is a test framework in python. To install pytest, we need to use the command pip install pytest. After installation, we can verify if python has been installed by the command pytest –version. The version of pytest shall be known.Pytest can be used for creating and executing test cases. It can be used in a wide range of testing API, UI, database, and so on. The test file of pytest has a naming convention that it starts with test_ or ends with _test keyword and every line of code should be inside a method that should have a name ...

Read More

What are some of the rules of creating a CSS expression?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 19-Nov-2021 441 Views

There are some rules for creating a CSS expression. The CSS is one of the important locators in Selenium. A customized CSS can be developed with the help of attributes like id, class name, and by the combination of tagname and html attributes.The ways of creating a CSS are listed below −Using a class name html attribute.This will select the web element of that particular class represented by (.)classname.Syntax− driver. find_element_by_css_selector(".name")Here name is the value of the attribute class.Using an id html attribute.This will select the web element of that particular id represented by (#) id.Syntax− driver. find_element_by_css_selector("#search")Here search is ...

Read More
Showing 21–30 of 590 articles
« Prev 1 2 3 4 5 59 Next »
Advertisements