程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Robotframework Python call RF keyword

編輯:Python

background

To tell the truth, there are some wonderful flowers in this demand , Because the normal framework will not use this requirement , Or pure Python To achieve , Or pure RobotFramework To achieve , use RobotFramework Can be called normally Python Of , But the other way around, it hurts a little .

Our current framework is based on RobotFramework Realized , But because of RobotFramework Scalability is too low in some places , Sometimes use Python To achieve more efficiency , But the existing RobotFramework There has been a lot of sedimentation in the project , If you rewrite this part completely , It's too much work , So there is such a wonderful demand . After searching the Internet for more than half a day , Finally gave up , I can only look at the source code to realize it .

Simple and crude implementation

There is a very simple and crude implementation , use RobotFramework Write a test case , Then the use case calls the corresponding keyword , Reuse Python To execute this use case , To achieve the function of calling keywords , But there are two drawbacks .

  1. Write test cases every time you call keywords , Very trouble
  2. If you want to get the return value , It hurts

More elegant implementation

The whole part is not difficult to implement , It's just RobotFramework There is no one to interpret the source code of , There is no good translation document , In fact, it was used in the previous analysis article robot.api This point has been covered in , The implementation code is as follows :

<
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved