RobotFramework : scope of variables - 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)"]

Related

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

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.

selenium send key for xpath not working

I want make automation for this web site
in this web site 3 text box are here check image
1st text box x path is /html[1]/body[1]/div[3]/div[1]/div[2]/div[1]/searchbar[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/input[1]
here is my code
driver.findElement(By.xpath("/html[1]/body[1]/div[3]/div[1]/div[2]/div[1]/searchbar[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/input[1]")).sendKeys("rio salon");
when I run this code I got this error
Exception in thread "main"
org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard
How can i fix it? I hope my xpath is correct.
The field has aria-hidden=true attribute, so you get ElementNotInteractableException. You need to click on the dropdown first to change the attribute to true
WebElement dropdown = driver.findElement(By.xpath("//*[#id='search-form']/div/div[1]/div/div[1]/span"));
dropdown.click();
WebElement textField = dropdown.findElement(By.xpath("./parent::div/following-sibling::input[contains(#class, 'ui-select-search')]"));
textField.sendKeys("rio salon");
You can click in an input field with a div or span tag, but you cannot type in the field. So, your XPath must be written with an input tag if you want to sendkeys or type in an input field. For example:
//input[contains(#placeholder,'Site')]

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

Returning to usage's location after Intellij IDEA "Create on Usage" intention action

Suppose I type a Java method call with an argument that I intend to make into a field:
knownObject.knownMethod(newField);
At this point, newField is highlighted as compilation error. I can press Alt+Enter and select "Create Filed 'newField'" from the menu.
That brings me up to the beginning of the class file where other fields are defined.
I can press Enter to confirm the new field's type.
Now I'd like to go back to my knownMethod() call and continue coding. How do I do that?
Bonus question: in the above situation, Ctrl+Shift+Backspace may help because I just edited the the knownMethod() call. What if I decide to first type in multiple arguments to the method? How do I get back to the argument I've just created a field for in that case?
For getting back to a previous caret location the Navigate > Back menu item usually works (CtrlAltLeft Arrow on Windows). Another option may be to use Edit > Find > Find Usages on the field (enable the Skip results tab with one usage checkbox setting)

Save a user popup selection in a custom Automator Action

Using Xcode 5.* for a cocoa-applescript automator action.
Interface is a a simple popup menu that gets populated using an outlet with:
tell thePopupMenu to removeAllItems()
tell thePopupMenu to addItemsWithTitles_(theList)
When the action is used in a workflow (a Service actually), I want the next time it is run and the action dialog shows up (I will have "Options:Show when run" selected), I want the popup menu to change the selection to the last one that was selected. Right now, the default first item shows, even though last time it was run, the user selected a different item in the popup menu.
My thought was that I need to capture a change in the popup menu with a Sent Action handler, and then set some type of default. I have a working handler:
on thePopupMenuSentAction_(sender)
set popupValue to (popupSelectedValue of my parameters()) as string
-- save this selection somewhere???
end
What's the right way to save this? Do I use User Defaults? My Bindings are currenly all tied through Parameter object/controller. If I should use User Defaults, can someone give example code for setting up User Defaults, and then how to get and set a new value using Cocoa-Applescript?
If I can get the name string of the menu item saved somewhere, I can get the string and then change the selection of the popup menu in the
on opened {}
-- set up the action interface
end
handler which gets called just before the action is displayed each time.
Thanks for any help,
Joe
I did mine a bit differently. I will assume you are referring to what XCode calls a "pop up button" (somewhat misleading). I did not use the parameters at all, although that is probably better for larger projects. Have a look at the code:
script Insert_Picture_into_Powerpoint_Slide_Show
property parent : class "AMBundleAction"
property menuChoices : {"Insert a Beginning", "Insert at End"}
property menuSelection : missing value
if (menuSelection as string) is "missing value"
set menuSelection to 0 as integer -- sets default value
end if
end script
I bound Content Values to File's Owner and under Model Key Path I put menuChoices.
Then you just bind the Selected Index to File's Owner and for the Model Key Path type menuSelection.
Defaults
On the initial run, if the user does not click anything, the menuSelection will be missing value. Because I couldn't find a way around this, I created a conditional which tests for this and sets it to the first choice by default (the one that is shown when you add the action).
When the user selections one of the menu choices, the choice is remembered on sequential runs.