当前位置:网站首页>Introduction to robotframework (I) brief introduction and use

Introduction to robotframework (I) brief introduction and use

2022-07-06 02:37:00 Makasa

Preface

This chapter focuses on Robotframework Brief introduction and use of



One 、 Brief introduction

Robotframework: It's based on Python Language Developed , Extensible , yes Keyword driven mode Automatic testing framework of ,Robotframework The latest version is 2019 year 7 in ,7 Before the month, only python2.7,7 Support after months 3.X Version of

First of all, let's talk about it briefly 【 Keyword driven mode 】 and 【 Data driven mode 】 The meaning of :

  • Keyword driven mode : That is to put Some logic is encapsulated into keywords ( A function name ), Then we can call Different keywords The combination realizes different business logic , So as to drive the execution of test cases
    for example :UI In automation , Each use case step can be written as a method , And then in robot Directly reference this method name in

  • in addition Data driven mode : Namely Realize parameterized data
    for example : stay API In automation , For example, for the framework pytest/unittest, We usually implement parameterization , Put your Parameters are uniformly written in external files (excel、yaml、txt、csv…) in , Then parameterize the request by reading the external file , In this case, we only need to maintain and change your external files , Commonly used packages :@ddt

 Please add a picture description

Robotframework characteristic :

1) Editing use cases is simple , We can use robot,txt,tsv perhaps html Write use cases in the format of 

2) Automatic generation html Format test report and log (HtmlTestRunner.py,allure)

3) Not only has its own class library :
		Buitini( Test library ) 
		Collections( Collection library ) 
		Date Time( Time bank ) 
		ScreenShot( Screenshot Library )
 There are also many other practical class extension libraries :
		SeleniumLibrary(web automated testing )
		RequestsLibrary( Interface automation testing )
		AppiumLibrary(APP automated testing )

4) You can customize some keywords according to the needs of the project 

5) have access to GUI How to run , You can talk to SVN perhaps GIT And Jenkins Continuous integration 



Two 、RobotFramework download

#robotframework
pip install robotframework==3.1.2

#ride, Can be done GUI operation 
pip install robotframework-ride==1.7.4.1

#  After downloading, all the extension libraries will be placed in python\Lib\site-packages Under the folder 
# web Automated third-party libraries , Conduct UI Download during automatic operation ,
pip install robotframework-selenium2library 3.0.0
pip install robotframework-seleniumlibrary  4.3.0
#  Interface automation test library 
pip install robotframework-requests 
# appui Automated third-party libraries 
pip install robotframework-appiumlibrary

 Insert picture description here



3、 ... and 、Ride Basic use

1、 establish ride Desktop shortcuts

  • Normally install robotframework-ride You will be automatically prompted to create a desktop shortcut , But occasionally the creation fails , So let's talk about it here ride Shortcut creation

 Insert picture description here

#  Icon path : Yours python Under the path \Lib..
D:\Mikasa_develop\Python36\Lib\site-packages\robotide\widgets\robot.ico

 Insert picture description here


2、 Common shortcut key

# 1、 Search keywords 
F5

# 2、 Keyword auto completion 
ctrl+shift+ Space 


Four 、 Simple robot Use case practice

 Insert picture description here

1、 Create project (New Project)

  • File --> New Project,Type choice Directory,Format choice Robot

 Insert picture description here


2、 Create a module (New Directory)

  • Right click on the item --> choice New Directory

 Insert picture description here


3、 Create a test suite (New Suite)

  • Right click on the module --> choice New Suite

 Insert picture description here


4、 Create test cases (New Test Case)

  • Right click Suite --> choice New Test Case

 Insert picture description here


5、 Create a resource file (New Resource)

  • The resource file is 【 Custom keywords 】 The carrier of
    Be careful : It can only be created under the folder , And is txt Format

 Insert picture description here


6、 Create business keywords (New User Keyword)

  • Create a new business keyword under the resource file

 Insert picture description here


7、 Common keyword use case writing

  • These are robot Common keywords , But in fact, in our own project UI/App When automating , We usually use custom keywords

 Insert picture description here

 Insert picture description here


 Insert picture description here

robot According to the report :

 Insert picture description here

原网站

版权声明
本文为[Makasa]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060234569345.html