Contributions
How to script creating report and then email link to report location for ReadyAPI functional test
I need to find a method to create a report for a ReadyAPI functional test and then email a link to the report location. I want to be able to provide a report to users after they run a functional test.3 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.2KViews0likes6CommentsRe: Add multiple values from a table to request headers
@ChrisAdams- This works great! Thanks for all of your work and patience reading through my lengthy explanations. I did add one thing to the initialization script that I would like to note here for reference. I require an authorization header in the "Eligibility With Rules Request" that uses a bearer token from the "OAuth Token Request Step" result. Since I must intentionally delete all existing headers in "Eligibility With Rules Request" on each iteration of this test case, I needed to add code to create the header that contains that bearer token. This header is only created once for each request, so it made sense to me to add it to the initialization process since that only occurs once and is outside of the "Loop Test Header Select" loop that iterates through all of the header table entries from the "Test Header Select" Data Source. The steps in the current (although still incomplete as of this moment) test case: Code in the "Initialize Headers" Groovy script step, including what I added for the bearer token header (Authorization). This is all still basically your code that I adapted just for this additional purpose: // Need this to build the object for the headers... import com.eviware.soapui.support.types.StringToStringMap; // Get the test step of interest... def testStep = testRunner.testCase.getTestStepByName("Eligibility With Rules Request"); // Get the request object for the test step def testRequest = testStep.testRequest; // Create an empty map. def newHeaders = new StringToStringMap(); // Add the empty map to blow away previously added headers. testRequest.setRequestHeaders(newHeaders); // Define current headers after deleting all existing headers def currentHeaders = testRequest.getRequestHeaders(); // Create response token from previous OAuth Token Request step response def responseToken = context.expand( '${OAuth Token Request#Response#$[\'access_token\']}' ); // Create bearer substring and add Authorization response token def bearer = "Bearer "; currentHeaders.put("Authorization", bearer.concat(responseToken)); // Put the header into the request. testRequest.setRequestHeaders(currentHeaders); The Groovy script in the "Create Headers" step: // Need this to build the object for the headers... import com.eviware.soapui.support.types.StringToStringMap; // Get the test step of interest... def testStep = testRunner.testCase.getTestStepByName("Eligibility With Rules Request"); // Get the request object for the test step def testRequest = testStep.testRequest; // Grab the header and value from the header datasource for this iteration only... def header = context.expand( '${Test Header Select#TestRequestHeader_TestRequestHeaderKey}' ); def value = context.expand( '${Test Header Select#TestRequestHeader_TestRequestHeaderValue}' ); // Get headers we've added so far. On the first iteration this will be empty. def currentHeaders = testRequest.getRequestHeaders(); // Add the header from the current iteration currentHeaders.put(header, value); // Put the request headers back into the request. // Note : Default headers are still there. E.g. Connection, Accept-Encdoding, but you could use this method to override the default set if you so wish testRequest.setRequestHeaders(currentHeaders); // Let's have a look. For each iteration, this log statement will get bigger. log.info(testRequest.getRequestHeaders()); log.info("EwR Header: '${header}' EwR Value: '${value}'. ");3 years agoPlace ReadyAPI QuestionsReadyAPI Questions686Views0likes0CommentsRe: Add multiple values from a table to request headers
@ChrisAdams- Yes, the "Test Header Select" Data Select that retrieves the headers will select all of the header records for the associated test case record selected in "Automation Test Select" (the current test record/iteration). So the script that adds the headers to the request must be able to write/add multiple Header/Value combinations from the multiple header records selected to the request, while also not overwriting the existing hardcoded headers already in the request. I hope that makes sense.3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2KViews0likes3CommentsRe: Add multiple values from a table to request headers
@ChrisAdams- Yes, the header records are selected in the "Test Header Select" data source. This Data Source step to select the header records occurs immediately before the "Eligibility_With_Rules_Request" request step where the headers are required. I could create a more complex query at the beginning of the test case to select all of the data I need across multiple tables, but for reasons specific to our business, and for the sake of simplicity, I have broken the selects out into simpler select statements in different Data Sources that occur just prior to each step that requires data from that table(s). The initial "Automation Test Select" Data Source selects all of the test cases required for the test case. The subsequent selects/Data Sources use a foreign key in each of the associated tables to perform a select based on the primary key in the "Automation Test Select" Data Source result set. Since the test case iterates through the result set from Automation Test Select, each subsequent select statement in the other Data Sources selects only the records in the other tables associated with the current record from the "Automation Test Select" Data Source. Each "HeaderKey" from the table would be passed to the "Header" request header field and each "HeaderValue" would be passed to the "Value" request header field. I hope that clarifies how this test case is structured, and how I am attempting to get the header data I require for each iteration of this test case. The headers I'm attempting to pass from the Data Source are in addition to the headers already shown in this screenshot. The select statement from the "Test Header Select" Data Source: Select TestRequestHeader.AutomationTestId as TestRequestHeader_AutomationTestId, TestRequestHeader.TestRequestHeaderKey as TestRequestHeader_TestRequestHeaderKey, TestRequestHeader.TestRequestHeaderValue as TestRequestHeader_TestRequestHeaderValue From TestRequestHeader Where TestRequestHeader.AutomationTestId = ${Automation Test Select#AutomationTest_AutomationTestId}3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2KViews0likes5CommentsRe: Add multiple values from a table to request headers
ChrisAdams - Would you be able to expand on your existing code example? I need to retrieve all of the header rows (usually more than one) from an existing Data Source step (embedded, not scripted) and then add the values to headers in a POST request step. Sorry if that wasn't clear from my original example. I'm new to using Groovy and I'm having a difficult time finding relevant examples. I'm also not having much luck finding a list/library of functions/methods available. The auto complete feature for a line of code I attempted to write ("testRunner.testCase.testSteps["Header Table"].) didn't provide me with a method of retrieving the number of result rows, for instance, and I couldn't find any reference to this in a web search either. Any help would be appreciated. Thanks.3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2KViews0likes7CommentsRe: Add multiple values from a table to request headers
About the headers. The names of the headers are defined within the APIs themselves, so they don't actually vary from request to request for the same API. I created a database for data driven testing. With that in mind, part of the design is to use the same ReadyAPI test for as many test cases as possible. That means making that one ReadyAPI functional test as generic as possible. One of the ways to do that is to use an EAV (Entity-Attribute-Value) approach to some of the tables, including the table that stores the headers for each test case. Instead of having a table that contains a lot of columns, one for each specific header in each API, I have a header table that only has two columns instead: One column for the name of the header and the second for the value (EAV approach). That is why I need to create a request that can load multiple headers with associated values from that table, but without knowing what the name and value of each header is prior to run time of the request. It appears the only way to do this is to script the request itself, even if I use embedded functionality for data selects, validations, etc...Looks like I'll need to research Groovy and scripting a request test step. Thanks for the response.3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2KViews0likes9CommentsAdd multiple values from a table to request headers
Is there a method for adding values from multiple records from a table (or any source) to a request name/value combination (header for instance) without knowing the "Name" and "Value" values prior to loading them? Example: SQL table name: RequestHeader SQL table Fields: ID, HeaderKey, HeaderValue In ReadyAPI: A POST request where "Name" and "Value" properties under the "Request" tab in the request must be populated from the table. "Name" = RequestHeader.HeaderKey "Value" = RequestHeader.HeaderValue There could be zero or more entries in this "RequestHeader" table for multiple, discrete test cases. The name and value of each header are unknown to the ReadyAPI request prior to being loaded to the "Name/Value" properties in the "Request" tab from the table at run time. I want to be able to load multiple records from the table to the request header so that value from the "HeaderKey" field in each record loads to a discrete "Name" property and the value from "HeaderValue" field in each record loads to the associated "Value" property. Can this be done in the provided ReadyAPI request object or will this require a request that is scripted in Groovy? If this request must be scripted, are there any examples of this specific scenario?Solved3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.8KViews0likes12CommentsMultiple data sources in sequence
Question: Is it possible to run multiple Data Sources in sequence in one test case, and use a value from the current iteration from the first Data Source result set that runs earlier in sequence to retrieve records from a second Data Source that runs later in the sequence using a single, matching value? I have attempted to do this but the functional test always fails. 1. These two Data Sources are currently the only two steps in this functional process. 2. It seems as if the second Data Source is using not only data from the current record/iteration from the first Data Source, but rather trying to run the select query in the second Data Source using the entire result set from the first Data Source.I assumed the second Data Source would only use values from the current record/iteration from the first Data Source. 3. I am directly referencing the key value field Property from the first Data Source in the select query in the second Data Source as part of the "Where" clause. 4. There is currently only one entry in each table and the key values in each record are the same value. Query: Data Source 1: Select AutomationTest.AutomationTestId As AutomationTest_AutomationTestId, AutomationTest.TestName As AutomationTest_TestName From AutomationTest Data Source: AutomationTest_Select Property: AutomationTest_AutomationTestId DataSource 2: Select AutomationTestInput.AutomationTestInputId As AutomationTestInput_AutomationTestInputId, AutomationTestInput.AutomationTestId As AutomationTestInput_AutomationTestId, AutomationTestInput.InputModel As AutomationTestInput_InputModel, From AutomationTestInput Where AutomationTestInput.AutomationTestId = ${AutomationTest_Select#AutomationTest_AutomationTestId} Error message: Test Case [EwR - Test Case 1] failed [java.lang.Exception: Failed to prepare the test step [AutomationTestInput_Select]; com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '='.:java.lang.Exception: Failed to prepare the test step [AutomationTestInput_Select]; com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '='.], time taken = 714568Views0likes1Comment