I have this very simple robot script to launch notepad.exe and type some text. The Test passes, but it doesnt launch notepad.
I am using Windows 10, python 3.7.1 and here are my versions of python packages:
Appium-Python-Client==0.31
decorator==4.3.0
docutils==0.14
kitchen==1.2.5
Pillow==5.4.1
pywin32==224
robotframework==3.0.4
robotframework-appiumlibrary==1.5.0.1
robotframework-autoitlibrary==1.2.2
robotframework-seleniumlibrary==3.2.0
selenium==3.141.0
six==1.11.0
urllib3==1.24.1
My robot scripts reads like this:
*** Settings ***
Library AutoItLibrary
*** Test Cases ***
AutoIT Notepad Test
Run notepad.exe
Wait For Active Window Untitled - Notepad
Send This is some text
What am I doing wrong?
If you have notepad in the default location, try this:
*** Settings ***
Library AutoItLibrary
*** Variables ***
${notepad} C:\\Program Files\\Notepad\\notepad.exe
*** Test Cases ***
Run ${notepad}
Send This is some text
I think I figured it out. The test was passing be notepad was getting launched in a hidden window. I gave it the addtional argument and it passed:
*** Test Cases ***
AutoIT Notepad Test
Run notepad.exe ${EMPTY} 1
Wait for active window Untitled - Notepad
Send Typing some text
Related
This is my robot code, here main.py takes input from events.json(I modify this using robot code) and generates a text file. main.py only stops running when it satisfies a condition, after running it will create a text file and I want to terminate the program and then read the results of text file.But the problem is if i run the below code the test cases are not executing the robotcode keeps on running.
See this
robot framework
*** Settings ***
Library JSONLibrary
Library OperatingSystem
Library Process
*** Variables ***
#{events} READY_TO_WAIT STARTING COMPLETE
*** Test Cases ***
Testcase with correct events and checking final state is DONE
Testing with correct events events-Create Dict/Convert json to string/create file
validating state.txt to check if its ending the state with DONE
*** Keywords ***
Testing with correct events events-Create Dict/Convert json to string/create file
Run Process ${CURDIR}${/}main.py
FOR ${event} IN #{events}
${new_dict}= Create Dictionary event=${event}
${json_str1}= Convert Json To String ${new_dict}
Create File ${CURDIR}${/}events.json ${json_str1}
END
Terminate All Processes
validating state.txt to check if its ending the state with DONE
${result}= Get File ${CURDIR}${/}state.txt
Should Be Equal ${result} DONE
How do I run python scripts and terminate them manually?
I am having trouble output/saving the results from my terminal commands.
*** Settings ***
Library Process
Suite Teardown Terminate All Processes kill=True
*** Test Cases ***
Example
Run Process adb devices -l
Current Output
Expected Output
However, if i just run adb devices -l, it will provide me with a list of android devices id.
E.g. List of devices attached
0429329319 device usb: xxxx
My attempts
Based on the robot framework, it has this example that i tried to follow but gave me errors such as "No keyword with name ${result} = Run Process found"
Sample code from robot framework
${result} = Run Process program stdout=${TEMPDIR}/stdout.txt stderr=${TEMPDIR}/stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Another way that i have discovered is to use 'Get Process Result' keyword.
So my question is - how do i print/save the output of my terminal commands?
Would appreciate if anyone can take a look at it
Referenced to
http://robotframework.org/robotframework/latest/libraries/Process.html
https://github.com/robotframework/robotframework/blob/master/atest/testdata/standard_libraries/process/get_process_result.robot
I just found out one way would be using the OperatingSystem library - 'Run'.
Then log the results of the command entered into the terminal/command prompt using 'Log To Console'
*** Settings ***
Library OperatingSystem
*** Test Cases ***
Get list of devices
${result} = Run adb devices -l
Log To Console [${result}]
To save the printed stuff in the console, just do
robot xx.robot > console.txt
Referenced to - how to run commands in CMD prompt using robot framework
I'm trying to invoke a shell scrip from within a .robot test case.
The .sh file is in the same folder as the .robot file
*** Settings ***
Library Process
*** Test cases ***
Run the shell script
Start Process ./getIDfromDB.sh shell=yes
I'm getting the error:
Setting variable 'Start Process ./getIDfromDB.sh' failed: Invalid variable name 'Start Process ./getIDfromDB.sh'.
Running on Ubuntu
Researched documentation for Robot framework but could not find a solution. Maybe digging in the wrong spot.
I'm not sure how you are trying to set the path of the shell script in the robot file. The error message seems to convey that something is wrong with the way you're initialising the variable to hold the path.
The following code should work:
*** Settings ***
Library Process
*** Variables ***
${pathToScript} ./getIDfromDB.sh
*** Test cases ***
Run shell script
${output} Run process ${pathToScript} shell=yes
The return code and the output displayed in the terminal are stored in the ${output} variable. You can access the details as ${output.rc} and ${output.stdout} respectively.
You can find more details about the result object here.
According error details the keyword is not recognized, I think, you need add extra spaces after keyword name:
Start Process ./getIDfromDB.sh shell=yes
I am trying to include_init_.robot file in the test suite. I have added a test implementation to check the method it would work, however I am unable to figure out it's execution. Code is as follows:
init.robot
*** Settings ***
Documentation Suite description
Suite Setup Initialization In Progress
*** Keywords ***
Initialization In Progress
log many THE CODE WORKS NOW
test#1.robot
*** Settings ***
Documentation Suite description
*** Test Cases ***
Test Case Execution
log many TC EXECUTED
Code used to run the test: pybot folder_name
The name of the first file is incorrect. You have
_init_.robot
while it should be
__init__.robot
When you do that the log will show this:
I want to import library SeleniumLibrary into Robot test file but resulted not found. What could be the error?
I have installed SeleniumLibrary into C:\Python27\Lib\site-packages and set the environment variables. I"m using python 2.7.9
*** Settings ***
Documentation This is a simple test for Robot Framework
Library SeleniumLibrary
#Set Selenium Speed 2 seconds
*** Variables ***
#${homepage} http://www.amazon.com
#${chrome_browser} Chrome
*** Test Cases ***
Test title "Amazon"
[Tags] DEBUG
Open Browser http://www.amazon.com chrome
[Teardown] Close Browser
*** Keywords ***
Please help. Thanks.
Your SeleniumLibrary looks perfectly fine, the problem is the way you are calling the KW.
The error you are getting here because of below line
Open Browser http://www.amazon.com chrome
There should be two or four spaces between Keywords and Arguments and Arguments and ... , otherwise it will treat whole line as KW , which never going to exist
so change it like this
Open Browser http://www.amazon.com chrome
if it still throw an error, paste it here.
Solve by using four spaces between keywords and argument and argument.