Comments (4)
Would your scenario be solved by any of these?
-
Create a resource file with arguments embedded in the keyword name, load said resource file and overwrite the variable by whatever you are generating dynamically
-
Another approach would be to write your own keyword library, and overwrite the keyword name to use embedded arguments like so.
If not, could you say why these don't help?
from robotframework.
I don't even need embedded arguments, I can just add my keywords to a resource file or a library:
# res.resource
*** Keywords ***
Example user keyword
[Arguments] ${arg}
Pass execution msg
# gen.py
from robot.api import TestSuite
for index in range(10):
suite = TestSuite('Example Suite')
suite.resource.imports.resource('res.resource')
test = suite.tests.create('Example Test')
kw = test.body.create_keyword('Example User Keyword', args=['my arg'])
suite.run(output=f'output-{index}.xml')
But the point here is that this is cumbersome, compared to doing this directly from API.
from robotframework.
@Tattoo hi!
First of all - thank you for this issue. I started using robot framework recently, especially using programmatic API approach, so it helped me with a better understanding of programmatic API overall.
From my experience so far, I found out that all user keywords related to suite are stored in suite.resource.keywords
, so you can easily add your user keywords there, for example:
from robot.api import TestSuite
from robot.running import UserKeyword
for index in range(10):
suite = TestSuite('Example Suite')
user_keyword = UserKeyword('Example User Keyword', args=('${arg}',))
user_keyword.body.create_keyword('Pass Execution', args=('msg',))
suite.resource.keywords.append(user_keyword)
test = suite.tests.create('Example Test')
test.body.create_keyword('Example User Keyword', args=('my arg',))
suite.run(output=f'output-{index}.xml')
or you can pass your user keyword as dict:
from robot.api import TestSuite
for index in range(10):
suite = TestSuite('Example Suite')
suite.resource.keywords.append({
"name": 'Example User Keyword',
"args": ('${arg}',),
"body": [
{
"name": 'Pass Execution',
"args": ('msg',),
},
],
})
test = suite.tests.create('Example Test')
test.body.create_keyword('Example User Keyword', args=('my arg',))
suite.run(output=f'output-{index}.xml')
I hope that I understand you correctly and it'll be helpful for you. Let me know if I misunderstand you, maybe I can find another solution that suits better for your needs!
from robotframework.
It is true that it isn't currently possible to define a higher level keyword with child keywords in the execution model. Basically a keyword in the execution model represents a keyword call with name and arguments. The keyword to actually run is resolved during execution and can either be a user keyword with child keywords or a library keyword.
Being able to define higher level keywords directly would be convenient in some cases. In addition to making it easier to programmatically create tests with suitable abstraction levels, it would make it easier for library keywords and listeners to create keywords with child keywords. We already have some other related enhancements initially planned to be done in RF 8, so I add this issue to its initial scope as well.
from robotframework.
Related Issues (20)
- Add new section about style to User Guide HOT 1
- Add support for time strings containing "week" values HOT 3
- Extended variable syntax does not take effect HOT 1
- Logging doesn't work propertly if Robot is running on thread HOT 4
- list the IP addresses of all connected devices HOT 2
- Embedded argument support for examples in libdoc
- Python global variables not visible if class is created HOT 1
- ExecutionResult is returning a wrong start_time, end_time and elapsed. HOT 5
- Support using named arguments with non-string values programmatically HOT 1
- Support keyword aliases HOT 4
- Warning with page screen shot HOT 1
- More events for Listener interface ? HOT 1
- Update Dutch language file
- Enhance BDD support (GIVEN/WHEN/THEN) for French language
- `Evaluate` keyword doesn't take attributes added into `builtins` module into account HOT 1
- testdoc do not print Template Keyword used in doc
- V3 Listener Errors - takes 2 positional arguments but 3 were given HOT 4
- Splitlog: Support the ability to move *.js file into a subfolder HOT 1
- rebot is raise JSONDecodeError when output.json contains "Test Execution Errors" section HOT 3
- Comparing paths with single keyword HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from robotframework.