Comments (5)
@Brownies maybe https://github.com/sebastianciupinski/robotframework-listenerlibrary is what you are looking for
from robotframework.
@Brownies maybe https://github.com/sebastianciupinski/robotframework-listenerlibrary is what you are looking for
If I understood its functionality correctly it's not quite what I'm looking for. I could use Register Start Keyword Listener
for every keyword but in that case I might as well use Setup
for those keywords and that's what I want to avoid.
from robotframework.
The reason this functionality hasn't been implemented is that we haven't considered it too common for all or even most of the keywords in a same suite or resource file to have a same setup or teardown. Do you @Brownies have a concrete example about such usage? Implementing this shouldn't be too complicated and the design with Keyword Setup
and Keyword Teardown
settings would also be straightforward.
from robotframework.
This functionality would become more usable if we'd allow changing the default setup/teardown within a file like this:
*** Settings ***
Keyword Setup Setup 1 # The initial default setup
*** Keywords ***
Keyword 1
xxx
Keyword 2
yyy
*** Settings ***
Keyword Setup Setup 2 # New setup used with the subsequent keywords
*** Keywords ***
Keyword 3
zzz
Keyword 4
ååå
The above doesn't currently because default specified in the Settings section apply for the whole file. That's even true if the Settings section is positioned after the test or keyword section it affects. There have now and then been requests to allow changing test related settings (mainly the template), and although they have been rejected earlier I start to like that idea nowadays. The main benefit I see is that it would simplify implementing new parsers for Robot data (e.g. in C or Rust for performance), because a setting like Test Template
at the end of the file wouldn't anymore affect how earlier data should have been parsed.
Although the above is somewhat related to this issue, it absolutely would need a separate issue. Changing the behavior would also be somewhat badly backwards incompatible, so it would need a deprecation period. I may submit an issue about that at some point, but others can submit one already now if you find it important.
from robotframework.
Somewhat simplified example is that I have a resource file with a bunch of keywords for a REST API. I want the keywords to be independent in the sense that if the default credentials are good for what I'm doing, then all I need to do in a test file is to import the resource file and call the keyword. I want to use a single RequestsLibrary session per credential set if possible because I don't want to get hundreds of access tokens per test run. So I end up calling Get Token And Create Session
as the first step of every keyword in this file.
Note, we haven't actually upgraded to RF 7 yet so there's no [Setup]
sections in the keywords.
*** Settings ***
Library RequestsLibrary
*** Keywords ***
Get Token And Create Session
[Arguments] ${session_alias} ${username} ${password}
${session_exists} = Session Exists ${session_alias}
IF not $session_exists
${data} = Create Dictionary username=${username} password=${password}
${response} = Post ${REST_V1_BASE_URL}/token json=${data}
${headers} = Create Dictionary Authorization=${response.json()}[accessToken] Accept=application/json
Create Session ${session_alias} ${REST_V1_BASE_URL} headers=${headers} verify=True
END
Get Stuff
[Arguments] ${stuff_id} ${session_alias}=v1 ${username}=${REST_USERNAME} ${password}=${REST_PASSWORD}
Get Token And Create Session ${session_alias} ${username} ${password}
${response} = Get On Session ${session_alias} /stuff/${stuff_id}
RETURN ${response.json()}
Post Stuff
[Arguments] ${stuff} ${session_alias}=v1 ${username}=${REST_USERNAME} ${password}=${REST_PASSWORD}
Get Token And Create Session ${session_alias} ${username} ${password}
${response} = Post On Session ${session_alias} /stuff data=${stuff}
RETURN ${response.json()}[stuffId]
# And so on...
from robotframework.
Related Issues (20)
- AttributeError: 'function' object has no attribute 'run_cli' HOT 6
- The description of the Method (end_keyword) is incorrect in Robot Framework user guide for Robot Listener Version 3 HOT 1
- Acceptance tests fail if directory path contains spaces HOT 1
- Asynchronous _loop_ref should using the existing event loop if one exists
- Unnecessary repetition when using VAR for already defined variable value
- Duplicate Keywords when using custom name for library
- Not using custom library name in warning when library is empty
- Robot Listener3 Issue: Adding tags in 'result' works for test case and in 'data' works for user keyword. HOT 1
- `maxerrorlines` does not appear to work via `robot.running.model.TestSuite.run`
- Dictinaries are not accepted as-is in argument conversion with unions containing TypedDicts HOT 4
- `NotRequired` and `Required` not properly handled with Python < 3.11 in `TypedDict` conversion HOT 6
- Add variable file import related method to listener version 3
- Multiple keywords matching: 'User Login Successfully' in 'PageCommonActions'. HOT 3
- Logging HTML doesn't get embedded in the log.html HOT 1
- Creating user keywords with programmatic API HOT 4
- Incorrect syntax in for loop crashes RF and html reports are not generated. HOT 2
- Request to set implicit wait as a basic parameter to a keyword HOT 1
- Multiple imports of library does not create new instance
- Generate Random String fails to create strong password HOT 2
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.