Dynamic Programming Articles

Page 9 of 14

How to get a JSON field in a nested JSON using Rest Assured?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 17-Nov-2021 8K+ Views

We can get a JSON field in a complex nested JSON using Rest Assured. First, we shall obtain a Response body which is in JSON format from a request. Then convert it to string.We shall send a GET request via Postman on a mock API URL and observe its Response.Using Rest Assured, let us get the value of the Price field having the value as $150. It is part of the Items. We shall get the value of the Item Count field by traversing the path - Items.Price.ExampleCode 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 ...

Read More

How to get the size of an array within a nested JSON in Rest Assured?

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

We can get the size of an array within a nested JSON in Rest Assured. First, we shall obtain a Response body which is in JSON format from a request. Then convert it to string.Finally, to obtain JSON array size, we have to use the size method. We shall send a GET request via Postman on a mock API, and observe the Response.Using Rest Assured, let us get the size of the Location array within the nested JSON response. The size should be three since it contains information about three locations - Michigan, Indiana, and New York.ExampleCode Implementationimport static io.restassured.RestAssured.given; ...

Read More

How to incorporate TestNG assertions in validating Response in Rest Assured?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 17-Nov-2021 1K+ Views

We can incorporate TestNG assertions in validating Response in Rest Assured. To work with TestNG we have to add the below dependency in the pom.xml in our Maven project. The link to this dependency is available in the below link −https://mvnrepository.com/artifact/org.testng/testngTo verify a response with a TestNG assertion, we need to use the methods of the Assert class. We shall first send a GET request via Postman on a mock API URL and go through the response.ExampleUsing Rest Assured and TestNG, we shall verify the value of the Course field which is Automation Testing.Code Implementationimport org.testng.Assert; import org.testng.annotations.Test; import static ...

Read More

How to update the value of a field in a request using Rest Assured?

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

We can update the value of a field in a request using Rest Assured. This can be achieved with the help of the PUT request. A PUT request is used to pass data to the server for the modification of a resource. The difference between POST and PUT is that POST request is not idempotent.This means invoking the same PUT request numerous times will always yield the same output. But invoking the same POST request numerous times will create a similar resource more than one time.Let us send a GET request on an API and observe its response using Postman.Using ...

Read More

What are the role and Responsibilities of QA managers in Agile organizations?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 17-Nov-2021 785 Views

The roles and responsibilities of QA managers in Agile organizations are listed below −Discover new avenues of QA growth after researching and analyzing data.QA managers are responsible for setting standards and guidelines on the choice of automation tools. They should define the testing methodologies and status of defects.QA managers collaborate with the research and development team to set new recommendations and test methods to be introduced within the team.QA managers are responsible to identify and determine the training needs of the team.QA managers are responsible for building a team intelligently consisting of automation, manual testers, and tests experts.QA managers are ...

Read More

How to open chrome default profile with selenium?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 17-Nov-2021 13K+ Views

We can open Chrome default profile with Selenium. To get the Chrome profile path, we need to input chrome://version/ in the Chrome browser and then press enter.We need to use the ChromeOptions class to open the default Chrome profile. We need to use the add_argument method to specify the path of the Chrome profile.Syntaxo = webdriver.ChromeOptions() o.add_argument = {'user-data-dir':'/Users/Application/Chrome/Default'}ExampleCode Implementationfrom selenium import webdriver #object of ChromeOptions class o = webdriver.ChromeOptions() #adding Chrome Profile Path o.add_argument = {'user-data-dir':'/Users/Application/Chrome/Default'} #set chromedriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe", options=o) #maximize browser driver.maximize_window() #launch URL driver.get("https://www.tutorialspoint.com/index.htm") #get browser title print(driver.title) #quit browser driver.quit()Output

Read More

How to parse a JSON response and get a particular field from the response in Rest Assured?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 17-Nov-2021 11K+ Views

We can parse a JSON response and get a particular field from Response in Rest Assured. This is done with the help of the JSONPath class. To parse a JSON response, we have to first convert the response into a string.To obtain the response we need to use the methods - Response.body or Response.getBody. Both these methods are a part of the Response interface.Once a Response is obtained it is converted to string with the help of the asString method. This method is a part of the ResponseBody interface. Then we shall obtain the JSON representation from the response body ...

Read More

How to use Selenium WebDriver for Web Automation?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 17-Nov-2021 747 Views

We can use Selenium webdriver for web automation. For this we need to follow the below steps −Step 1 − The Webdriver should be created. For example,    WebDriver driver = new ChromeDriver();The above piece of code is used to create a webdriver instance and initiate the script execution in the Chrome browser.Step 2 − Launch the URL on which we want to perform the UI testing. For example,    driver.get("https://www.tutorialspoint.com/index.htm");The above piece of code shall launch the URL passed as a parameter to the get method.Step 3 − Identify web elements with the help of any of the locators ...

Read More

How to verify JSON response headers in Rest Assured?

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

We can verify JSON response headers in Rest Assured. This is achieved with the help of the header method. We shall send a GET request via Postman on a mock API, observe the Response Headers.Headers −ExampleUsing Rest Assured, we shall verify the value of the Content-Length in the Headers.Code Implementationimport org.hamcrest.Matchers; import org.testng.annotations.Test; import static io.restassured.RestAssured.given; import io.restassured.RestAssured; public class NewTest {    @Test    public void ressponseAssertion() {       //base URL       RestAssured.baseURI = "https://run.mocky.io";       //GET operation       given() .when().get("/v3/6c6ed634-5e78-4b80-94c7-cf17c04c7055").       then().log().all()       ...

Read More

How to pass the request body from an external file in a separate package in Rest Assured?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 17-Nov-2021 1K+ Views

We can pass the request body from an external file in a separate package in Rest Assured and pass that file directly to a request as a payload. This technique can be used for static payloads or payloads having slight changes.The RequestSpecification interface has a method called the body. It is an overloaded method that can send payloads in various formats.Let us create a JAVA file, say PayLoad.java, and add a request body in the below format. This is created within the project in a separate package.Code Implementation in PayLoad.javapackage files; public class PayLoad {    public static String pay_load() ...

Read More
Showing 81–90 of 132 articles
« Prev 1 7 8 9 10 11 14 Next »
Advertisements