I have test case to delete files one by one, i want it to click each file till there is no file.
but actual execution just delete one file and stopped.
is that i need to implement for loop?
please advise how to do it in robot.
Delete All Files
Wait Until Page Contains And Click ${SETTINGS-FILES}
${FILES} Run Keyword And Return Status Wait Until Page Contains Element ${ANDROID-WIDGET-LISTVIEW}\[#resource-id="FilesList"] 2s
Run Keyword If ${FILES} Wait Until Page Contains And Click ${DELETE-FILES}
Run Keyword If ${FILES} Wait Until Page Contains And Click ${OK}
Run Keyword If ${FILES} Wait Until Page Does Not Contain Element ${ANDROID-WIDGET-LISTVIEW}\[#resource-id="$FilesList"]
Run Keyword If ${FILES} Wait Until Page Contains No Files
A very rough solution
FOR ${i} IN RANGE 999999
YOUR TEST
Exit For Loop If CONDITION TO EXIT
END
Related
My robot is made under the producer-consumer model, on the consumer robot side previously I had one cycle (as how normally a consumer robot works) which takes a series of files listed under the work item json file created on the producer robot on the first step, these files are uploaded onto a website, and then checks the status of that same file under a table of the website, the entire workflow is like this:
*** Tasks ***
Consumes file data work items
Open DT webpage
For Each Input Work Item Process work items
Close Browser
But now I have to split the cycle into two:
one cycle takes only the uploading task, then after all the files are finished, a new second cycle should do the check of each file status, but after I configured the robot like this:
*** Tasks ***
Consumes file data work items
Open DT webpage
For Each Input Work Item First cycle
For Each Input Work Item Second cycle
Close Browser
I noticed when I use the 'For Each Input Work Item' on the second cycle, it just got ignored and doesn't execute the listed keywords (just shows it as PASS and doesn't do any keyword order), but if I leave the 'second cycle' task alone, it does all of them, but obviously, doesn't make a cycle for all the work items, so the question is:
How I can load the work items as a FOR cycle without calling the 'For Each Input Work Item' function?
I have an action set in Photoshop that I would like to repeat infinitely.
As the image below, the action set runs 8 batch processes and then ends.
Is it possible to run the action set (F8) automatically again after the last script in the action set has completed?
I have considered using a .bat file to press F8 and use a JSX to call that BAT file at the end of the action set, however, I cannot get this to work so far.
Any help is really appreciated.
Could you please help me out that how Run Keyword If works in RIDE?
I want to click the "EXIT" button if there is any online error in the page after clicking on "Create" Button. I have put the code like this. But it did not work. After running, the test case did not fail but at the same time, the EXIT button was not clicked also.
Click Button xpath=//*[#id="divHeader"]/table/tbody/tr/td[5]/input
${Result} Page Should Contain Element //*[#id="divError"]
Run Keyword If '${Result}'=='PASS' Click Button xpath=//*[#id="MyForm"]/div[4]/table/tbody/tr/td[2]/input
Expected: As there is an online error, It should click the "Exit" button.
Page should contain doesn't return a result. It either throws an exception or returns None.
If you need to get the pass/fail status of a keyword you need to use Run keyword and return status. However, it doesn't return "Pass" or "Fail". It returns the a boolean (either True or False).
${result} Run keyword and return status
... Page should contain element //*[#id="divError"]
You can use the value directly as the condition in Run keyword if, like the following:
Run keyword if ${result}
... Click Button xpath=//*[#id="MyForm"]/div[4]/table/tbody/tr/td[2]/input
i want to know how to display a message in console when an element is not found with robot framework:
I tried this:
S2L.Wait Until Page Contains Element ${checkbox} 10s checkbox not found
It's not working for this element and don't know why. It works for any other element but not for my checkbox.
So for now i have this:
Wait Until Keyword Succeeds 5 times 2 sec S2L.Click Element ${checkbox}
But when it fails it says only the element not found bu i would prefer to code a personalized message.
Any help is welcome.
Thank you
Although I do think that your problem is something different, your question can be answered. Run Keyword And Return Status will capture the error and continue and provide a status. Run Keyword If then allows for using the keyword Fail and it will also generate a message on the console.
*** Settings ***
Library SeleniumLibrary
Suite Teardown Close All Browsers
*** Test Cases ***
Wait And Click succesfully
Open Browser http://google.com HeadlessChrome
Wait and Click Element name:q This should work
Wait And Click unsuccesfully
Open Browser http://google.com HeadlessChrome
Wait and Click Element name:nobtn This should not work
*** Keywords ***
Wait and Click Element
[Arguments] ${locator} ${message}=None
${status} Run Keyword And Return Status
... Wait Until Keyword Succeeds
... 5 times 2 sec
... Click Element ${locator}
Run Keyword If
... "${status}" == "False"
... Fail ${message}
How about using the error argument available with the Wait Until Page Contains Element keyword?
Wait Until Page Contains Element id=elementId timeout=60s error=Display whatever you want, e.g. Lorem Ipsum...
I am new to Robot Framework and I am trying to use Run Keyword If .. ELSE ...
What it should do:
Add a new keyword to perform a check if a page includes the word "closed". If it does, refresh the page. If it doesn't, click element "this" and proceed with the rest of the scenario.
*** Keywords ***
Check if anything is closed
${ClickThis} Click Element xpath=//*[#id="this"]
${Closed} Page Should Contain Element xpath=//*[text()='Closed']
Run Keyword If ${Closed} =='PASS' Reload Page ELSE ${ClickThis}
What happens when I run it:
"Closed" does not appear in the page. "this" is clicked. Then the test fails because:
Page should have contained element 'xpath=//*[text()='Closed']' but did not
Please, help me in correcting it.
Edit: changed Page Should Contain to Page Should Contain Element. Same results.
The argument after the ELSE should be another keyword.
What effectively happened is that on this line
${ClickThis} Click Element xpath=//*[#id="this"]
you've assigned value to ${ClickThis} - which is nothing, ${None}, as Click Element doesn't return a value.
On this line, you're again assigning ${Closed} the return value of Page Should Contain
${Closed} Page Should Contain xpath=//*[text()='Closed']
, which is not you expect it does - that itself keyword either fails (as was in your case) if the text is not there, or silently passes; but doesn't return a value.
So, to get to what you try to accomplish, use Run Keyword And Return status for the "page should contain" - it will return True/False according to the exit status of the wrapped keyword:
${Closed}= Run Keyword And Return Status Page Should Contain xpath=//*[text()='Closed']
Now ${Closed} will have value of ${True} if the text was in the page, ${False} otherwise; use that in the Run Keyword If block, passing a keyword as the 2nd argument:
Run Keyword If ${Closed} Reload Page ELSE Click Element xpath=//*[#id="this"]