good morning!
I'm automating tests using Robot Framework with Sikulli Library.
I have the following problem, I don't even know how to do it:
I would like to create a keyword in a file with a Wait Until Screen Contain and then a click. The goal is to keep it standardized and not keep repeating it over and over again.
And in the other files create keywords using the keyword in the file. Then I would only add the keyword, I wouldn't need to add a wait and click.
Would?
First file example:
*** Keywords ***
clickButton
Wait Until Screen Contain ${IMAGE}.png 3
Click ${IMAGE}.png
Second file example:
*** Keywords ***
testOne
clickButton imageOne
The "imageOne" is the image name saved.
Waiting!
Thank you!!
CodePudding user response:
It can be done by importing the first file as a resource. Here is the documentation. In your case it would look something like this:
file1.resource
*** Keywords ***
clickButton
[Arguments] ${IMAGE}
Wait Until Screen Contain ${IMAGE}.png 3
Click ${IMAGE}.png
file2.robot
*** Settings ***
Resource ${RESOURCES}/file1.resource
Resource path/to/file/file1.resource
Resource ${CURDIR}/path/file1.resource
Resource file1.resource
etc
*** Keywords ***
testOne
clickButton imageOne
There are several options for importing the file. Use variable in the path, variable can be easily set when runnung the tests. Use absolute path, you can even use ${CURDIR}, or just with the file name if the files are in the same folder or you have it in your python path
${CURDIR} An absolute path to the directory where the test data file is located. This variable is case-sensitive.