[TechCorner Challenge #8] How to Clear Cookies in API Request
Hello Community! I am back with another interesting task for you. Here is the task: create a Groovy script that will clear the cookies that are sent with the request. Difficulty: Assume that you have a TestCase in ReadyAPI with several test steps and for some of them, you need to maintain the HTTP session, i.e. to send the Cookie HTTP header. You can achieve this task by using the Maintain HTTP session option of the TestCase. But, for other requests in your Test Case, cookies cause failure. In this case, you may need a script that will remove the Cookie header for these test steps. For example, you have the following configuration of your ReadyAPI test: You need to write a script that will remove the cookies only for the “Login Server 2” and “Get Info Server 2” test steps. Note that there could be several or zero Cookie headers in the requests. Expected Task Results:the implementation of this task requires a Groovy script to be created. Tip:Working With Headers Good luck!Solved6.2KViews0likes17Comments[TechCorner Challenge #10] Connecting to JMS using Groovy script
Hi Community! The TechCorner Challenge continues. You can put your skills to the test and learn something new about the tool, as well as bring more valuable content to the ReadyAPI Community! And, those who complete tasks, will get into the Leaderboard. This week's task: Sometimes, the JMS test step doesn’t suit you since you might have custom JMS settings, or you need to add additional logic before or after sending/receiving a JMS message. In this case, you can use Groovy scripts. So, try writing a sample script to connect to JMS that can be used as a basis for further customization. Task: write a script for the Groovy Script test step which creates a connection to a JMS provider (ActiveMQ, WebSphere or another), sends a JMS message to the “Test“ queue, and shows all messages in this queue. Difficulty: Notes: use the manual connection, not the HermesJMS session. Check out the TechCornerLeaderboardand detailed participation rules here. Good luck, as always!Solved5.4KViews0likes9Comments[TechCorner Challenge #7] Change an XPath Match assertion to a JSONPath Match assertion
Imagine that the logic of the server has been changed and you started getting responses from the server in the JSON format instead of XML. And, it may appear that XMLPath assertions don’t suit you anymore. In this case, you need to convert all XPath Match assertions to JSONPath Match assertions in your project. There could be a lot of test steps to change, so it’s better to automate this process. Task: Create a script to convert XPath Match assertion to JSONPath Match assertion for the REST test steps where the request URL is the following: https://example.com/test. Difficulty: A script should do this: 1. Add the JSONPath Match assertion to REST test steps that have the https://example.com/test endpoint. 2. Convert the XPath expression and expected result from the XPath Match assertion to the JSONPath expression and expected result for the corresponding test steps. 3. Remove the XPath Match assertions for those test steps. A sample response: JSON XML { "id": 1111, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 99, "name": "string" } ], "status": "available" } <Response xmlns="https://petstore.swagger.io/v2/pet"> <id>1111</id> <category> <id>0</id> <name>string</name> </category> <name>doggie</name> <photoUrls> <e>string</e> </photoUrls> <tags> <e> <id>99</id> <name>string</name> </e> </tags> <status>available</status> </Response> XMLPath Match assertions example: Condition: declare namespace ns1='https://petstore.swagger.io/v2/pet'; //ns1:Response[1]/ns1:tags[1]/ns1:e[1]/ns1:id[1] Expected result: ${#TestCase#ID} Tips: https://support.smartbear.com/readyapi/docs/soapui/steps/groovy.html#working-with https://support.smartbear.com/readyapi/apidocs/soapui/DefaultPackage/XPathContainsAssertion.html https://support.smartbear.com/readyapi/apidocs/pro/DefaultPackage/JsonPathContentAssertion.html Good luck and have fun😊Solved5.4KViews0likes10Comments[TechCorner Challenge #15] Fetch a value/data from a JSON response using a Groovy Script
Hello ReadyAPI Community! We have another task for you to put your ReadyAPI knowledge to the test. Check out the participation rules and the TechCornerLeaderboardhere. In this task, we will have a scenario in which you need to iterate throughout a JSON response to find a specific item/value from it. You should stop once the value has been found. Task: Find a specific value in a JSON response using a Groovy script Difficulty: Here is what your script should do: 1. Iterate through all the test steps in a test case that have JSON responses. 2. Compare the value given (VeryImportantString) with all the values in the JSON response. 3. Once the value is found, return it. If there is no such value in the response, return “The value wasn’t found“. JSON response example: { "id": 1111, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 99, "name": "string", "Additional info": [ { "ad1": "VeryImportantString", "ad2": "NoteVeryImportantString" } ] } ], "status": "available" } Helpful Tips: Iteration Sample Code: def TesCaselist=context.testCase.testSuite.getTestCaseList() TesCaselist.each{ def steps=it.getTestStepList(); //'it' is used for referring to current item steps.each{ (CHECK SMTH)? <DO SMTH>:<DO SMTH ELSE> } Good luck!Solved5.2KViews0likes5Comments[TechCorner Challenge #1] How to add a new tag and assign it to all TestCases in a TestSuite?
Hi Community! As you know, we have aTechCorner label, a place where tons of useful information about ReadyAPI is stored. We would like to make this section even bigger. I would like to encourage you to share more great content with all ReadyAPI community members under this label: use cases, tips, scripts, script templates, all the helpful things you are using in your daily testing with ReadyAPI. Here’s one request that we get a lot from users,that you can help with: Create a script, that can add a newtagand then assign it to every TestCases in a TestSuite Difficulty: A link that will help you choose the right methods ofworking with tags at the TestCase level. Tags are a neat feature of ReadyAPI, they help group TestCases and give more control over the testing process. This script is going to be very useful for ReadyAPI users. Who will contribute?🙂Solved5.1KViews0likes10Comments[TechCorner Challenge #9] A script to include custom details to the report
Hi ReadyAPI Community! I bring more challenges 🙂 If you have the "Complete error logs" option enabled, the printable report includes the Raw request and Raw response for the failed test steps. But, you may need to get this info for passed test steps, as well. Currently, there is no built-in option in ReadyAPI to show raw request and response of passed test steps in the printable (Jasper) report. Task:Write a Groovy script for the "TestRunListener.afterStep"event that will post the raw request URL and the full raw response to the printable report. Difficulty: Here is an example: 💡Hint:https://community.smartbear.com/t5/SoapUI-Pro/TechCorner-Challenge-9-A-script-to-include-custom-details-to-the/m-p/205242/thread-id/46875 Check out the TechCornerLeaderboard here. Good luck😊Solved4.4KViews0likes7Comments[TechCorner Challenge #14] Filtering data retrieved from a DataSource
Hi ReadyAPI Community! We’ve prepared an interesting task for you to solve today! Check out the participation rules and the TechCornerLeaderboard here. Imagine that you are working with an app for setting up online conferences, and you need to filter data based on certain criteria. In our case - the location of an online conference participant. Task: Create a script that will filter data retrieved from a DataSource Difficulty: Here’s what your script should do: 1. Take an item in a DataSourse and check if it matches the criteria. 2. If it does, run the test. If it doesn't - skip the item. The Excel file to be used as a DataSource is attached below. Condition: Run the test only when participants of an online user conference are located in Boston. Resources: Here are some examples of working with DataSources in Groovy scripts:https://support.smartbear.com/readyapi/docs/testing/scripts/samples/data.html The full description of the class - here you can find all the properties and methods that the class has: https://support.smartbear.com/readyapi/apidocs/pro/DefaultPackage/WsdlDataSourceTestStep.html Good luck!Solved4.1KViews0likes7Comments[TechCorner Challenge #4] How to Generate a Request Body Based on Data from Datasource
Hi everyone, Thank you for your TechCorner input! It has beenawesome an extremely helpful. I've got more challenges for you🙂 A request body can be dynamic, and it is not always possible to use the existing ReadyAPI functionality to create it. One use case example could be changing data before sending a request. This is when users need to come up with a custom script. Your task for today is to write a script that will read data from an Excel file and generate a request body for the SOAP TestStep based on it. The number of rows in the Excel file is dynamic. Difficulty: Tips: https://smartbear-cc.force.com/portal/KbArticleViewer?name=Example-of-using-third-party-Java-libraries-in-Groovy-script-reading-from-Excel-file-using-Apache-POI&sp=all https://community.smartbear.com/t5/SoapUI-Open-Source/Dynamic-request-creation-with-Groovy-element-Create/m-p/127999/thread-id/21964#M24011 Excel example: Request body example: <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"> <soap:Header> <m:Trans xmlns:m="https://www.w3schools.com/transaction/" soap:actor="https://www.w3schools.com/code/">234 </m:Trans> </soap:Header> <soap:Body> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <PRICE>10.90</PRICE> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <PRICE>9.90</PRICE> </CD> <CD> <TITLE>Greatest Hits</TITLE> <ARTIST>Dolly Parton</ARTIST> <PRICE>9.90</PRICE> </CD> <CD> <TITLE>Still got the blues</TITLE> <ARTIST>Gary Moore</ARTIST> <PRICE>10.20</PRICE> </CD> </CATALOG> </soap:Body> </soap:Envelope> Have fun when solving this!😊Solved3.8KViews0likes3Comments[TechCorner Challenge #13] - Call Database Connection Using Groovy Script
Hello ReadyAPI Community! We have returned with a task for you to attempt. See the participation rules and the TechCornerLeaderboard here. Participate in the challenge and earn new unique badges! Check out some of these awesome rewards: In this week’s task, we will be having you use scripting to connect to a database. Task: Create a Groovy script that will connect to a database Difficulty: Steps to follow: 1.Create a database connection using the ReadyAPI interface. 2. From your script, call the database connection, connect to the database, and return a success message on a successful connection to the database. Good Luck!Solved3.6KViews0likes6Comments[TechCorner Challenge #6] How to Generate Email When Assertion Fails
Hello Community! Today we have another task for you to help contribute to our collection of useful ReadyAPI content. Here is the task: Create a Groovy script that will send an email when an assertion fails Difficulty: The idea of the script is to run a send email test step when the assertion fails. Please note that the email should be sent if any assertion for any test step in a project fails. To complete the task you should write a script for one of the events. Good luck😊Solved3KViews0likes6Comments