Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 862 of 3363
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
11K+ Views
We can verify the JSON response body using Assertions in Rest Assured. This is done with the help of the Hamcrest Assertion. It uses the Matcher class for Assertion.To work with Hamcrest we have to add the Hamcrest Core 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.hamcrest/hamcrest-coreWe shall send a GET request via Postman on a mock API, observe the Response.Using Rest Assured, we shall verify the value of the Location in the Response body.Code Implementationimport org.hamcrest.Matchers; import org.testng.annotations.Test; import static io.restassured.RestAssured.given; import io.restassured.RestAssured; public class NewTest { ... Read More
1K+ Views
We can upload files to S3 using Rest Assured multipart with the help of the below techniques −Rest Assured has the default URL encoding feature. The issue with S3 URLs is that they contain special characters such as %2A, %3D. As the URL encoding feature is configured to true value by default in Rest Assured, we are required to set it to false so that the special characters are not transformed to ASCII equivalent value during runtime.Syntax −given().urlEncodingEnabled(false)Rest Assured appends a default charset to the content. This causes a problem if the content type is not given. In some scenarios, ... Read More
2K+ Views
We can parameterize tests with multiple data sets using Rest Assured. Using data providers we can execute a single test case in multiple runs. To know more about TestNG data providers visit the below link −https://www.tutorialspoint.com/testng/testng_parameterized_test.htmThis technique can be used for dynamic payloads. For this, we shall create a Java class containing the payload.Then in the second Java class (having the implementation of the POST request), we shall pass the dynamic fields of the payload as parameters to the request body.Please find the project structure for the implementation below.Code Implementation in NewTest.javaimport org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static io.restassured.RestAssured.*; import io.restassured.RestAssured; ... Read More
924 Views
We can create a project with Cucumber and Rest Assured dependencies. This can be done by following the below steps −Step 1 − 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.htmStep 2 − Add the following dependencies in the pom.xml file in a project for Cucumber.Cucumber JVM - Java dependencyCucumber JVM - JUnit dependencyhttps://mvnrepository.com/artifact/io.cucumber/cucumber-junitStep 3 − Add the following dependencies in the pom.xml file in the project for Rest Assured.Rest Assured dependencyhttps://mvnrepository.com/artifact/io.rest-assured/rest-assuredJackson Databind dependencyhttps://mvnrepository.com/artifact/com.fasterxml.jackson.core/jacksondatabindRead More
322 Views
The all() method in the pandas series is used to identify whether any False values are present in the pandas Series object or not. The typical output for this all method is boolean values (True or False).It will return True if elements in the series object all are valid elements (i.e. Non-Zero values) otherwise, it will return False. This means the pandas series all() method checks for whether all elements are valid or not.Exampleimport pandas as pd series = pd.Series([1, 2, 3, 0, 4, 5]) print(series) #applying all function print(series.all())ExplanationHere we have created a pandas series object ... Read More
876 Views
DataFrame is used to represent the data in two-dimensional data table format. Same as data tables, pandas DataFrames also have rows and columns and each column and rows are represented with labels.By using the python dictionary we can create our own pandas DateFrame, here keys of the dictionary will become the column labels, and values will be the row data.Here we will create a DataFrame using a python dictionary, Let’s see the below example.Example# importing the pandas package import pandas as pd data = {"int's":[1, 2, 3, 4], "float's":[2.4, 6.67, 8.09, 4.3]} # creating DataFrame df = pd.DataFrame(data) ... Read More
3K+ Views
The pandas DataFrame constructor will create a pandas DataFrame object using a python list of tuples. We need to send this list of tuples as a parameter to the pandas.DataFrame() function.The Pandas DataFrame object will store the data in a tabular format, Here the tuple element of the list object will become the row of the resultant DataFrame.Example# importing the pandas package import pandas as pd # creating a list of tuples list_of_tuples = [(11, 22, 33), (10, 20, 30), (101, 202, 303)] # creating DataFrame df = pd.DataFrame(list_of_tuples, columns= ['A', 'B', 'C']) # displaying resultant DataFrame ... Read More
343 Views
In pandas Series functionalities we have a function called add_prefix that is used to add a string prefix to the labels. Particularly in pandas series the row labels will be prefixed with string.The add_prefix method will return a new series object with prefixed labels. It will add the given string before the row labels of the series.Exampleimport pandas as pd series = pd.Series(range(1, 10, 2)) print(series) # add Index_ prefix to the series labels result = series.add_prefix('Index_') print("Prefixed Series object with a string: ", result)ExplanationIn this following example, we have created a pandas series using python range ... Read More
10K+ Views
The pandas DataFrame can be created by using the list of lists, to do this we need to pass a python list of lists as a parameter to the pandas.DataFrame() function.Pandas DataFrame will represent the data in a tabular format, like rows and columns. If we create a pandas DataFrame using a list of lists, the inner list will be transformed as a row in the resulting list.Example# importing the pandas package import pandas as pd # creating a nested list nested_list = [[1, 2, 3], [10, 20, 30], [100, 200, 300]] # creating DataFrame df = pd.DataFrame(nested_list, columns= ... Read More