简体   繁体   中英

Robot framework keyword creation mapped to python class structure

I have just started to look at adding robot framework on top of our current pytest based system.

In our test we are doing things like:

network."subnetX".setDelay(200)

network."subnetY".setRandomLoss(20%)

machine.engine.start()/stop()

machine.clutch.engage()/disengage()

machine."somethingelse".engage()/disengage()

machine.engine.setRPM(1200)

machine."somethingelse".set"somethingelse"(300)

How would one go ahead and create a keyword mapping that would support this kind of three/four keyword combo + sometimes one argument so that I can write somethings along the lines of:

set networkY delay 200ms

Set networkX random loss 20%

Start machine engine

Engage machine clutch

Start machine engine

Set machine engine RPM 1200

Set machine 300

This would require a custom Robot Framework Library. In the User Guide the Chapter Extending Robot Framework the section Creating test libraries explains how to create a custom (Python/Java) module whose methods/functions can be used as keywords in Robot Framework script. This includes Keyword Arguments and in the Keyword Names section a paragraph on embedded arguments explains the options you have there.

As the library instance is able to retain state, you can use keywords to set certain variables or store connections to external systems for use by other keywords.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM