calling a test case within a test case in SOAP UI - properties

I am trying to call a test case within a test case using SOAP UI Pro. I created a reusable test case to generate a random VIN and intend to call this test case within other test case where applicable. I used property transfer, but I am unable to set the property in the test case to the value being returned.
I created a test case, wrote a groovy script, added a property to the test case and added a property transfer.See picture
I have been unable to set the property vin (highlighted) as shown in the picture. Any help would be appreciated.

I think this works with "DataGen" option.Lets say you have 2 testcases TC1 and TC2 Right click on TC1-> choose DataGen and add a property, write the groovy script for generating the random VIN.
Go to the TC2 where you want to reuse the VIN, right click on the property name and click on "get data" ->TC1->property name.
https://www.soapui.org/data-driven-tests/reference/datagen-teststep.html

Related

Test Data not showing in All Steps page in Cluecumber report plugin

I am generating the cluecumber report. When ever the report is generated , in the All Steps page the test data is not getting populated rather the steps are showing empty angular brackets like {}.
The test case is written as -
#Regression
Scenario: Create a new Modifiers
Given item image is clicked
When modifiers option is selected
And modifier is created as **"ModifierName"**
And enter modifier option and modifier price as **"Mod"** and **"3.50"** respectively
And hit save
Then verify modifier is created as **"ModifierName"**
**
See the below image for how it is generating now.**
enter image description here
pom file looks like this-
enter image description here
enter image description here
I wish test data passed in feature file to appear in steps while report is generated in All Steps Page and no {} empty brackets.
The all steps page shows which step implementations are used in which scenarios. This is independent of parameter values.
In the scenario details you see the data you need since here the steps are used with concrete values.

Karate UI automation, is it possible to make locators dynamic

Thanks Peter for API,Perf karate framework.
Now I am trying UI automation and it looks perfect as of now.
I have below question:
I have a menu bar with 15 items in it. they are named as following:
-Home
-Account
-groups
-settings
etc etc.
Locator for each one is like this "a[name=Home]" , "a[name=Account]", "a[name=groups]" . So ony the part after name= is something that is dynamic in nature. So my question is that is it possible to somehow make this dynamic locator?
I have written a called feature in which i have written steps to login and select a menu item. and I want to pass the menu item from calling feature in json like below:
if I want to click on Account menu
* call read(menuItem.feature) {menuItem: Account}
menuItem.feature looks something like below:
Given url 'xyz'
And input (username, userID)
And input (password, password)
And click("button[name=login]")
And click("a[name=Home]")
Here I want to make Home as dynamic in last click step on menuItem.feature so that I can pass other menu items and reuse all above steps/feature file to login everytime with different menu items passed from calling feature file in json{.
Again its just a query. I have currently written multiple scenarios to click on menu item and then in calling feature I call the called feature with tags like #Home,#account etc. and this works perfectly fine.
Also if there is any other better way to achieve this then please suggest
Yes. Let me put it this way, the things you see such as input('foo', 'bar') is pure JS behind the scenes. So normal programming-language rules apply. For example:
* def dynamic = 'foo'
* def locator = 'a[name=' + dynamic + ']'
* input(locator, 'some value')

How to get the IDObject with Attribute in SAP using Automation Anywhere with DLL?

I'm developing an automation process on SAP with Automation Anywhere using the SAP DLLs provided by Automation Anywhere itself. I need to find IDObject with specify attribute to click/get value the specify element , but seems that there are no fuctions that allow you to do it. An example of code generated from the SAP recorder is the following:
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell").setCurrentCell 0,"ICON_EXEC"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell").selectedRows = "0"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell").clickCurrentCell
using the dlls I have already tried the following functions:
Step 1 : Login on existing session (in this case 0)
Step 2 : Search Object by ID (in this case wnd[0]/shellcont[1]/shell/shellcont[0]/shell )
Step 3: CurrentCellRow (in this case 0)
Step 4: DoubleclickCurrentCell
The problem is that it doesn't click where i want, because as you can see there is the attribute "ICON_EXEC" that specify the element that i want to click . (i also tried to insert in the SearchObjectbyID all the string with the attribute, but it doesn't work)
Currently to avoid that i'm using Execute VBscript, but it seems that error handling does not work with scripts, so i would like to avoid them too
Any tips?
Thanks,
U.
You can find out the SAP-Object ID (IDObject) by recording a (.vbs-)macro in SAP:
Hit Alt + F12 or click the respective icon and choose "Record script and playback" ("Skript-Aufzeichnung und -Playback" in my screenshot):
In the following dialogue window, hit the record button and click the desired object:
Open the recorded .vbs-macro and and look for something like this (=the desired object ID):
You can handle errors in sap vb script , please refer below articles as reference and handle error as per you requirement.
1) https://answers.sap.com/questions/9676858/error-while-logging-to-sap-through-excel.html
2) https://wiki.scn.sap.com/wiki/display/Img/Scripting%3A+Error+Handling+and+Debugging

How to assign a keyword to Group of Test Cases at one time in TestLink?

I want to add a keyword to some of the test cases in my test specification. May I know whether there is any easy way of doing it other than adding the keyword to each test case manually?
Any help is appreciated. Thanks in advance.
You can assign keyword to multiple test cases under specification's node.
Select Desktop item from top nav bar menu in Testlink
From the left select Test Specification -> Assign Keywords
Specifications' tree is opened - select the needed node (test suite)
In Keyword Assignment frame from the right assign with > button keyword from available ones to Keywords to be assigned.. and click Save
As result all test cases under the selected node will get the assigned keyword.
You may also filter test cases by some of available filter fields and then assign the keyword (using the process described above) but with "Assign ONLY to filtered Test Cases" checkbox activated, so only filtered TCs will get the needed keyword.

How to use variable, which value should be set in keyword or test, in XPATH?

I need to click on element based on what value it contains..but I want to set this value in test run or keyword definition (best option is in the test I guess)
How should I do it?
the variable containing xpath should look like that:
${DROPDOWN ITEMS} xpath=//*[contains(#class,'listitem-element')]/span[contains(text(),'${second_number}')]
This locator works when I replace the variable with actual number like '002', but I want to have it more general..
In keyword definition I use it like:
Choose Value From Dropdown
focus ${DROPDOWN ITEMS}
click element ${DROPDOWN ITEMS}
and in test I just call the keyword
my question is where and how to set the variable value of ${second_number} variable used in xpath?
PS:the xpath definition, keyword and test are each in separate files
thank you!
I use similar approach in my SUT, as it works with fairly complex objects, both precreated and dynamically generated during the tests executions - and their main user-identifiable attribute is the displayed name. Here's simplified version of my flow, and it's based around string substitution.
Starting off from the variables file - a simple collection of selenium locators, the value of the locator has a "special" string, which will later be substituted:
*** VARIABLES ***
${DROPDOWN ITEMS} xpath=//*[contains(#class,'listitem-element')]/span[contains(text(),'SELENIUM_PLACEHOLDER_CHANGE_ME')]
Then, in the keyword files there are private keywords for returning the proper locators, for example for this one:
*** KEYWORDS ***
_Return Selenium Locator For The Dropdown Item Named
[Documentation] Verifies the desired dropdown item is valid, ando returns its locator (not Webelements!!)
[Arguments] ${name}
# change the placeholder with the actual UI name
${loc}= Replace String ${DROPDOWN ITEMS} SELENIUM_PLACEHOLDER_CHANGE_ME ${name}
# why? Rationale explained below
Element Should Be Visible ${loc} message=The dropdown does not have an item called ${name}
[Return] ${loc}
Why the visibility check? Simple - to fail as early as possible if there's no such object currently in the SUT, and to have uniform error message, independent of how is the element further used (clicked on, checked for presence, attribute retrieval, etc.)
Then, a follow up user keyword for performing actions on the element uses the previous one:
# the user keywords
Choose Value From Dropdown
[Documentation] It does what it does :)
[Arguments] ${the value}
${loc}= _Return Selenium Locator For The Dropdown Item Named ${the value}
# as you can see, no checks is the element real - that'she offloaded to the helper keyword ^
Focus Element ${loc}
Click Element ${loc}
Finally, the test cases use the keyword to work with any data you deem neaded:
*** TESTCASE ***
The dropdown should do X
[Documentation] Steps: 1, 2, 3, etc
# do the normal steps you'do do
Choose Value From Dropdown my current value
This approach applies fairly well for negative tests also - for example, to check a value is not present, a test case would contain:
Run Keyword And Expect Error The dropdown does not have an item called no_such_element Choose Value From Dropdown no_such_element
Thus we're both using selenium checks for the absence of the element, and keeping the test case close to real-life expression - a description of what should happen, with no special syntax and SE keywords.
please excuse any typos and minor syntax omissions - it's not easy to type on a mobile that much, next time I'd think twice before taking it on :D
You can define variables when you fire off your test suite by using arguments.
Here is the documentation for it
Right now, you would leave your xpath as it is. Keeping the ${second_number} inside. Now you can either define it within the argument or within the argument file. They do the exact same thing, but one is neater. Just to get it working I would just worry about putting it directly in the console.
pybot -v second_number:002 nameOfTestFile.robot
This will tell pybot to create a variable called ${second_number} with the value of 002. It does not save this inside the test, so after the test is completed, it will forget the variable.
Once this works, you can then move this into a Argument file Or if you want you can even define it inside a Variable file where you can store all of your variables and then call them within the argument file / within the console.
Any questions do ask and ill try to help out
how about using the set suite variable keyword?
we can use Evaluate keyword for framing dynamically changing xpath
*** Variable ***
${common xpath} xpath=//label[contains(text(), '{0}')]
${text to be replaced} my name
*** Keyword ***
Frame xpath based on user input
${final xpath} Evaluate "${common xpath}".format("${text to be replaced}")
log ${final xpath}
RESULT
In ${final xpath}, you will have the "xpath=//label[contains(text(), 'my name')]"