I have selected a radio button and I need to double check that its actually selected in the Robot framework - radio-button

My page is having multiple Radio buttons and I have selected one of them. Now I need to double check whether its actually got selected and if its True I would like to drive my flow accordingly. Here is how I tried using the Robot Framework
Click Element //*[text()=' Small' ] //*[#name='size']
Radio Button Should Be Set To xpath=(//*[text()=' Small' ] //*[#name='size']) true
I am not sure about the things I specified in the second line. Is this correct

This should do it:
Radio Button Should Be Set To size true
The argument to provide to Radio Button Should Be Set To is not an xpath or other locator, but the group's name.
What the framework does with the argument is to substitute it in this xpath:
xpath://input[#type='radio' and #name='%s']
, get all matching elements, iterate thorough them to find the selected one and assert - case sensitively! - its value is the same as your second argument.
And now you see why your call failed - having provided a full xpath, after the substitution it ended up as invalid/not matched expression and the keyword failed.

Related

Setting Default Values to Drop Down in Orbeon Form Builder

I have a autocomplete field:
I need to set the default value selected for this dropdown using another control value as shown in:
This control is passed to the form load as shown in:
For example if use cost center is 110 as shown in:
Then the default selected value of the Site lookup dropdown needs to be as shown in:
The tricky part is that your Site-Item field isn't a dropdown but an autocomplete. An autocomplete doesn't know all the possible label/values, but can only find some label/values doing a search by label. So you can't tell an autocomplete "set your value to 110", because it doesn't know what the label corresponding to 110 is.
If you knew the label, you could do this programmatically with an fr-set-label, but here you don't have the label but the value. You can read more about this in the section Setting by value. So, my advice is to use a Dynamic Data Dropdown instead of an Autocomplete field.

RobotFramework : scope of variables

I have a problem with the ${testAccount} variable.
When I modify this variable in the user keyword "Modify user name", the Log informs me that the modification is correct.
When I use this variable in the keyword "Change activation", it is equal to the initial value and not the modified one.
Here is the script I wrote :
*** Keywords ***
Modify user name
Set Global Variable ${testAccount}
Wait Until Element Is Visible xpath=//a[#ng-click="openCreateEditModal(tenant)"]
Click Element //td[text()='${testAccount}']/following-sibling::td//a[#ng-click="openCreateEditModal(tenant)"]
Wait Until Page Contains Edit an account
Click Element xpath=//input[#ng-model="tenant.name"]
Press Key xpath=//input[#ng-model="tenant.name"] \\08
${testAccount}= Get Substring ${testAccount} \ -1
Click Button xpath=//button[#ng-click="valid()"]
Wait Until Page Contains ${testAccount}
Change activation
Wait Until Element Is Visible xpath=//a[#ng-click="openCreateEditModal(tenant)"]
Click Element //td[text()='${testAccount}']/following-sibling::td//a[#ng-click="openCreateEditModal(tenant)"]
I tried to use the keywords 'Set Global Variable' or 'Set Suite Variable', but it doesn't work any better. Maybe I don't use them properly.
Could you, please, help me understand ?
Simply add the 'Set Global Variable' keyword after the line that modifies the contents of the variable ${testAccount}. Thus the new content of this variable will be taken into account in the following testcase until it changes again.
You can use Set Suite Variable Keyword.
Follow the below link
http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Suite%20Variable
Also use Return Statement at the end of first Keyword 'Modify user name' and use the variable '${testAccount}' as an argument in the second keyword 'Change activation'
Check the code below.
Modify user name
Set Suite Variable ${testAccount}
Wait Until Element Is Visible xpath=//a[#ng-
click="openCreateEditModal(tenant)"]
Click Element //td[text()='${testAccount}']/following-sibling::td//a[#ng-
click="openCreateEditModal(tenant)"]
Wait Until Page Contains Edit an account
Click Element xpath=//input[#ng-model="tenant.name"]
Press Key xpath=//input[#ng-model="tenant.name"] \\08
${testAccount}= Get Substring ${testAccount} \ -1
Click Button xpath=//button[#ng-click="valid()"]
Wait Until Page Contains ${testAccount}
Return ${testAccount}
Change activation ${testAccount}
Wait Until Element Is Visible xpath=//a[#ng-click="openCreateEditModal(tenant)"]
Click Element //td[text()='${testAccount}']/following-sibling::td//a[#ng-
click="openCreateEditModal(tenant)"]

Tosca: How to scan Dropdown textbox which disapper upon opening xScan

I have a problem in scanning a drop-down menu which disappears upon opening the xScan. I need to get the module id of the dropdown menu to verify some test steps.
Do you have any solution with this if it is not really possible to get the module id of the dropdown menu?
Open developer tools in your browser of choice (F12), navigate to the console and input the following code:
var fulldoc='';
var scrollX=0;
var scrollY=0;
document.addEventListener("keydown",function(event){
if(event.key=='q' && event.altKey){
fulldoc=document.body.outerHTML;
scrollY=window.pageYOffset;
scrollX=window.pageXOffset;
}
if(event.key=='w' && event.altKey){
document.body.outerHTML=fulldoc;
document.body.scrollTo(scrollX,scrollY);
}
});
When the window looks the way you would want to scan, press 'Alt + Q', then press 'Alt + W'.
Now your window will freeze and then you can scan your page.
To steer the objects you need to refresh your browser.
You can resolve the issue with below 2 steps
1 - Add some text in textbox which will populate the dropdown below it .
2 - Use Send Keys Module to scroll down and select the value.
I had a similar issue where we had a popup that only appeared when clicking on a text box. The solution we received from the Tricentis trainer was as follows:
Part One
1. Open your application in Chrome
2. Right click the inspect
3. In the inspector window, on the Elements tab, navigate to your html element where it should be (you can do that by clicking on the element and check that you can see the html in the element)
4. Use the debugger to add a break point there, this should pause it and you should be able to see the elements you need to steer it.
5. Once you found the element, you will need the type of element (e.g. div, span, etc), and the class name
Part two
1. Rescan your module and select any element that matches the criteria of your element selected in Part One #5
2. Identify it by only it's class name property and tag
3. Save and close
4. Edit the element in the module view by changing the class name. This should help you steer it
Note: if the element class name is not unique, you might need to use Explicit name.
Good luck

QTP - Clicking on a button with a given value

I've started using QTP last weekend so I'm still a bit confused about some things.
I've coded a function that opens an URL on IE, performs some actions and writes a report. But I have a little problem: at a certain point the function has to click on a button to go on but this button's value is changed at every refresh of the page.
For example: at the first access the button's value (or label) is "Results List (51)" but, if I refresh the page, the value becomes "Results List (11)".
What changes is the number inside the brackets (that identifies the number of results inside the list).
Obviously I recorded the action only one time and the result is this:
Browser("myBrowser").Page("myPage").Frame("myFrame").WebButton("Results List 51)").Click
How can I click on the button without having to worry about it's value?
You should open the object repository and have a look at the description that was create for your WebButton then make the property in question a regular expression.
In your case the value should be Results List \(\d+\), this means Result List followed by open-parentheses, followd by one or more digits (a number) followed by close-parentheses.
Here's an explanation on how to use regular expressions in UFT.
This question reminded me of the days when I was a beginner in QTP ;) I think I still am!
Coming to your question -
If you don't really care about what is inside the brackets then you can just give Results List*.* but if you want to check if there is a bracket and digits within it then use the value suggested by Motti i.e. Results List (\d+)
Detailed Steps as you are a rookie:
1) Go to Resources->Object Repository
OR
In the Resources pane expand your action and double-Click the local object repository (You recorded hence the objects will be in local)
2) Click on the Concerned Object so that the object properties specific to this object is displayed.
3) Select the property (name?), at the extreme right you will see a button to configure the value, click on it.
4) Type the text Results List (\d+) or Results List*.*, select the checkbox for regular expressions.
5) A message box will appear, Click on No and then OK button.
Your script should run now!

Selenium, using xpath to click a button with a similar content

I want to click a button that contains "Add" as text.
ie:
driver.find_element_by_xpath("(//a[contains(text(),'Add')])").click()
however it's not practical to do this:
driver.find_element_by_xpath("(//a[contains(text(),'Add')])[1]").click()
It would be fine, except the page has a button with text "Add User", and it clicks that instead. Is there a way to only click it if it is EXACTLY "Add" and not just contains "Add"?
You can also try :
driver.find_element_by_link_text("Add").click()
link text will match links who's text equals Add and it doesn't match text which contains Add as part of it.
This should work for you:
driver.find_element_by_xpath("//a[text()='Add']").click()
You should change your xpath to require an exact match instead of a partial match.
driver.find_element_by_xpath("//a[text()='Add']").click()
Using text()= requires the text on the button to be equal to 'Add' and will not find other buttons that happen to contain the text 'Add'