Build the most complete robotframework automated test environment in the whole network

I. Introduction

1. Before 2019, the version of robotframework-ride has always been 1.5.2.1, which is the version in January 2016. It can only be installed in the python2.7 environment, so if you want to use robotframework for testing at the same time, you need a python3 environment Friends who write python code need to install two python environments (2.7 and 3.7) on the operating system.

2. In 2019, robotframework finally ushered in this much-anticipated update to solve this problem. From now on, you only need to install a python environment above python3.6.

2. Install the robotframework automated test environment

1. Download and install Python3.7.4 (Note: Do not install the latest 3.8 version, if there is an old version, uninstall it first), and configure python environment variables.

 (1) Download and install python3.7.4

 Enter the python official website address: Welcome to Python.org Select Downloads-->Windows option. As shown below:

      

     Select the pythong3.7.4 windows64-bit version in the opened page. As shown below:

      

 After downloading, double-click to install, and modify the installation path to C:\Python37 (Note: Take this address as an example for the environment configuration), and click [Next] until it is completed.

      (2) Configure Python environment variables:

      Right-click My Computer --> Properties --> Advanced System Settings --> Advanced --> Environment Variables --> Find the path variable and click the "Edit" button --> Add the following content at the front of the path.

      C:\Python37;C:\Python37\Scripts; (Note: C:\Python37 is the installation path of Python, please change if the installation path is different)

      

2. Download Google Chrome and the driver package of the corresponding version of Google Chrome. (By the way, also add Firefox browser and the driver package download address of Firefox browser)

(1) Download browser: one of Chrome and Firefox. Google Chrome: https://www.google.cn/intl/zh-CN/chrome/ Download the latest version as shown in the picture:

       

     (2) Firefox browser: http://www.firefox.com.cn/download/#more download the extended version

(2) Download the browser driver package: Check the version of Google Chrome and download the corresponding version of the driver package of Chrome browser (the same version is enough)
        Chromedriver Google driver: http://npm.taobao.org/mirrors/chromedriver/
    
        Geckodriver Firefox driver: https://github.com/mozilla/geckodriver/releases
       Note: The version of the driver package needs to be consistent with the major version of the corresponding browser version. After downloading, put it in the python directory: such as: C:\Python37 

 

3. Install robotframework and robotframework- ride

1. Install robotframework

Enter the command in dos: pip install robotframework until the following interface appears, indicating that the installation is successful! (An error is reported due to network reasons, you can run the command repeatedly until the installation is successful.)

2. Install robotFramework-ride (this is rf's IDE integrated development environment)

Enter the command in dos: pip install robotframework-ride, it may take a while, please wait patiently. The following interface appears, indicating that the installation is successful.

Which installed: Pygments, Pypubsub, robotframework-ride, robotframework-exer, wxPython, etc.

Enter pip list in dos to check whether the above software is installed and their versions. As shown below:

 

Go to the C:\Python37\Scripts directory, right-click ride.py, and choose to open with python. The RIDE interface appears, indicating that RIDE is installed successfully.

4. Install the Selenium2Library package.

Because what we are going to do is UI automation testing, then its corresponding class library is: Selenium2Library, so Selenium2Library needs to be installed. Enter the command in dos: pip install robotframework-Selenium2Library, the following interface appears to indicate that the installation is successful.

 

At this point, the environment for developing UI automation using the robotframework tool has been installed. Then the next step is how to use robotframework and verify whether there is a problem with this automated test environment. Next, implement a case using robotframework.

 

Five, use robotframework to realize a case

1. Create a new UI automation project in RIDE, click File-->new Project in the menu bar of RIDE, as shown in the figure below:

2. Create a new test suite on the project, right click on the project Ecshop, new-->New Suite, as shown in the figure below:

Then import Selenium2Library in Suite. Left-click the [Login] suite to import the Selenium2Library class library, as shown in the figure below

3. Create a new test case on the suite, right-click on the suite 【Login】, New TestCase

4. Write a use case and open Google Chrome.

 

5. After running, automatically open Google Chrome and load the Baidu homepage, which means that the robotframework automated testing environment is finally perfect, and the next step is to be familiar with various keywords for operating browsers and the four-tier architecture of automated testing (element layer, business layer, use case) layer, process layer).

 

 6. Error resolution

1、application.py文件偶发性错误
Traceback (most recent call last):
File "d:\python\lib\site-packages\robotide\application\application.py", line 59, in OnInit
self._plugin_loader.enable_plugins()
File "d:\python\lib\site-packages\robotide\application\pluginloader.py", line 43, in enable_plugins
p.enable_on_startup()
File "d:\python\lib\site-packages\robotide\application\pluginconnector.py", line 52, in enable_on_startup
self.enable()
File "d:\python\lib\site-packages\robotide\application\pluginconnector.py", line 57, in enable
self._plugin.enable()

Solution:
According to the above prompt information, find the testrunnerplugin.py file path, as above is
d:\python\lib\site-packages\robotide\contrib\testrunner\testrunnerplugin.py
Open the py file with python code editing tools such as pycharm, edit Line 789:
Change font=wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT) to font=wx.SystemSettings.GetFont(wx.SYS_ANSI_FIXED_FONT)
If not successful, change to
font=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)

2. No permission to report error

After using the Text Edit area to write the code, when the code is saved, the following error will appear:

Error message:
Error in serializing 'C:\robotframeworkcode\newdream':
[Errno 13] Permission denied: 'C:\robotframeworkcode\newdream.'
Solution:
The main cause of the problem is that Robot Framework's RIDE does not have relevant permissions.
After forcibly closing the RIDE interface of Robot Framework, find the storage path of the ride.py file (python installation path\Scripts\ride.py),
Windows 7 operating system, right-click the ride.py file -- select administrator to take ownership.
For the Windows 10 operating system, right-click the ride.py file -- select Grant Access -- Specific User -- select the account you log in to Windows 10 to share.
 

Finally, I would like to thank everyone who has read my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, you can take it away if you need it:

These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey, and I hope it can help you! Partners can click the small card below to receive  

Guess you like

Origin blog.csdn.net/okcross0/article/details/132414949