Input inside a iframe RobotFramework - iframe

I am trying to input text into a field inside iframe. Select frame passed, but input text does not. Fails with an error:
Element with locator xpath=//iframe[#class='uvw-dialog-iframe'] not found.
Any help is appreciated.
- Select frame xpath=//iframe[#class='uvw-dialog-iframe'] --> Passes
- Input text xpath=//iframe[#class='uvw-dialog-iframe'] Test input --> Failes

Once you select the frame, it's like walking in a door. You are inside the frame, so the xpath should not contain the frame. You need to use a selector to the input element you want to type into.
For example, if you have an input element with the id the_input, you would do it like this:
select frame xpath=//iframe[#class='uvw-dialog-iframe']
input text id=the_input test input

Related

Robot frame work Input text : Element is not currently interactable and may not be manipulated

I am using chrome and trying to input end date to this field.
Tried this
wait until element is visible ${contract_end_date} timeout=50s
input text xpath=(//*[#name="terminatedMerchant.contractEndDate"]) ${mdy}
## input text xpath=(//*[#class="vds-input--input-text"])[3]
sometimes both xpaths works, sometimes it throws this error.
Typing text '07/07/2022' into text field
'xpath=(//*[#name="term.contractEndDate"])'.
13:18:50.275 FAIL InvalidElementStateException: Message: invalid
element state: Element is not currently interactable and may not be
manipulated (Session info: chrome=103.0.5060.114)
Element:
I cannot use ID as it keeps changing. Can you please assist in fixing this issue?
Thanks for your help.

RobotFrameWork: how can I use a function in a function?

So there's a nice keyword in RFW which is:
Table Cell Should Contain,
But now It should check the tabletext against a regexp. but it doesn't seem to work that way, because it says,
text not found
*** Variables
${pattern2} ^[0-9]{1}[0-9]{1}
Table Cell Should Contain xpath=//div[#id='components_block']/table 2 6 ${pattern2}
this doesn't work: either i guess:
Table Cell Should Contain xpath=//div[#id='components_block']/table 2 6 regexp:^[0-9]{1}[0-9]{1}
Regretfully, no, in Robot Framework you cannot chain keywords - to use the output of one directly as an input for another. You have to have intermediate/temp variables for that.
For the case here, you want to see does a table cell has text, matching a specific regular expression. As the keyword Table Cell Should Contain does not support regexp in the looked-for argument, but only normal strings, you can't use it.
Break down this verification in 2 steps - first get the text in the cell (in a temp variable), and then see does it match the regular expression with the Should Match Regexp keyword:
*** Variables ***
${pattern2} ^[0-9]{1}[0-9]{1}
*** Testcases ***
A case
${temp variable}= Get Text xpath=locator_that_will_return_the_specific_cell
# alternatively, you can use this keyword - if the table is an actual <table> element in the html
# ${temp variable}= Get Text xpath=locator_that_will_return_the_table 2 5
# now having the text in the cell, see does it match the regexp
Should Match Regexp ${temp variable} ${pattern2}
As to what are the values of "locator_that_will_return_the_specific_cell" and "locator_that_will_return_the_table" - I can't tell you; nor anyone else, without a sample of the HTML.
I found I direct match/hit to the table location like so: xptah=//tr[1]/td[4]
then I could do this:
${gettext} Get Text xpath=//tr[1]/td[4]
Should Match Regexp ${gettext} ^[0-9]{1}[.]{1}[0-9]{1}[0-9]{1}

In Robot Frame Work How Can we use value returned from one keyword as input argument to other keyword directly(without use of variable)

How Can we use value returned from one keyword as input argument to other keyword directly (without assigning return value to variable)
Currently I am maintaining all Web Elements or Variable names and corresponding xpath in an Excel Sheet. I get XPath using keyword read_xpath by passing web element/variable name as argument.
I store the xpath in separate variable then make use of it for other or Next line keyword. Since I need to use a variable for each XPath access, i am trying to find out, whether is there any way to directly use one keyword output as input to other keyword without assigning it to variable.
The main purpose of storing XPath in Excel sheet is to avoid multiple test cases change with single Element XPath change, making just single change on Excel Sheet should be sufficient.
For Example:
read_xpath reads values from a Excel sheet, Excel sheet has two columns, one variable name and second one is xpath. Function read_xpath(element) takes variable name as input and gives back xpath.
xlread.py file looks like xlread.py code Excel Sheet look like Excel sheet
sample.robot file looks as below
${login_user_textctrl}= read_xpath username_textctrl
clear element text ${login_user_textctrl}
Input text ${login_user_textctrl} admin
Now let us check how I used read_xpath keyword in my robot file
I called Keyword read_xpath with argument username_texctrl, which returns xpath for username text Control which is stored in variable ${login_user_textctrl}. Now Input Text ${login_user_textctrl} admin works fine.
For below code
clear element text read_xpath username_textctrl
I am getting, clear element text requires 1 argument but two arguments provided, is there any way i can use the the value returned from Keyword(read_xpath) as input to other keyword directly, without assigning it to any variable?
Thanks in advance.
Separating your locators from your robot code through an Object Repository is often done when the locators are reused a lot. An alternative implementation paradigm is to use the Page Object Model. An example of such an implementation can be found in the Robotframework-PageObjectLibrary.
In case you still prefer the Object Repository approach, then using the Selenium2Library keyword Add Location Strategy might be of interest to you. Below is a working example which uses a YAML file as it's OR to fetch the search input box and search button from Google.
ObjectRepo.yaml
OR:
searchbox: '//input[#id="lst-ib"]'
searchbutton: '//button[#id="_fZl"]'
Robot Script
*** Settings ***
Library Selenium2Library
Variables ObjectRepo.yaml
*** Test Cases ***
Yaml Object Repository
[Setup] Add Location Strategy yro Yaml Locator Strategy
Open Browser http://www.google.com Chrome
Input Text yro=searchbox Robot Framework
Click Element yro=searchbutton
Sleep 3s
[Teardown] Close All Browsers
*** Keywords ***
Yaml Locator Strategy
[Arguments] ${browser} ${criteria} ${tag} ${constraints}
${xpath}= Set Variable ${OR.${criteria}}
${retVal}= Get Webelement xpath=${xpath}
[Return] ${retVal}
As you can see the abstraction through a custom locator keyword allows for clearner code and not require you to fetch into a variable for later reuse.
You can use Evaluate to call python functions directly. Example:
${my element to clear}= Evaluate read_xpath("username_textctrl") xlread
See the documentation here
(Note: Example is untested and you should check if xlread is in PYTHONPATH, or found at test run time)

How to get text rendered in the cells?

How can I get text rendered in the cells? I have tried the following :
[1] $(gridId).jqxGrid('getcellvaluebyid', rowID, columnFields[j])
[2] $(gridId).jqxGrid('getcelltextbyid', rowID, columnFields[j])
However, I only get the actual values of the cells like flags and status codes instead of the actual flag names and status names rendered on the specific cell (using cells renderer).
Please help.
Have you tried by creating an Array variable and caching the cellsrenderer result using that Array. After that you can access the rendered cell content using your Array and your array keys.

QTP - getting value of element

I am beginning with QTP and just cannot find out how to get value of element. For example when I just want to compare the number of results found by google. I tried to select the element with object spy and use Val(Element) to assign the value into variable..but it doesnt work. Could anyone help with this? BTW, I am not sure whether selecting the text (element) to compare with Object spy is correct.
Thanks!
You should use GetROProperty in order to get the text and then parse it for the value.
Looking at a Google results page I see that the result is in a paragraph with id=resultStats in the 3rd bold tag.
<p id="resultStats"> Results <b>1</b> - <b>10</b> of about
<b>2,920,000</b>
for <b>qtp</b>. (<b>0.22</b> seconds)</p>
So the following script gets the number (as a string with commas).
Browser("micclass:=Browser")
.Page("micclass:=Page")
.WebElement("html id:=resultStats")
.WebElement("html tag:=b","index:=2").GetROProperty("innertext")

Resources