Selenium +RobotFrame 教程(一):安装及配置

Selenium +RobotFrame 教程(一):安装及配置

目录

  • Selenium +RobotFrame 教程(一):安装及配置
  • 1.开发环境的选择
  • 2.Selenium 的python安装
  • 3.RobotFrame 的安装
  • 4.Selenium WebDriver的下载配置
  • 4.Selenium WebDriver的加入环境变量
  • 5.启动RIDE,进行脚本编辑
  • 6.运行脚本测试环境

1.开发环境的选择

RobotFrame 是基于python进行开发的,所以这里我们选择Selenium的python环境搭建。
[官网](https://www.selenium.dev/downloads/)可以查看最新版本,最新的python版本是3.141.0

2.Selenium 的python安装

直接使用

pip install selenium

3.RobotFrame 的安装

安装robotframework

pip install robotframework

安装robotframework IDE

pip install robotframework-ride

安装selenium2library库

pip install robotframework-selenium2library

4.Selenium WebDriver的下载配置

Selenium支持几乎大部分主流游览器。支持列表如下:

  1. FirfoxSelenium +RobotFrame 教程(一):安装及配置_第1张图片
  2. Chrome
    Selenium +RobotFrame 教程(一):安装及配置_第2张图片
    驱动下载地址
  3. Edge
    驱动地址,注意如果安装的是Microsoft Edge Legacy,查看EdgeHTML version, 然后选择对应的驱动版本。
  4. IE
    IE只支持IE11,它的驱动2个版本,win32或win64, 建议下载win32版本,比较稳定。
    驱动地址
    注意:IE的驱动还需要进行如下配置
    1. On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose “Internet Options…” from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled “Enable Protected Mode”(WIN10 也需要进行设置)
    2. Additionally, “Enhanced Protected Mode” must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog.
    3. The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
    4. For Windows 10, you also need to set “Change the size of text, apps, and other items” to 100% in display settings.
    5. For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.
  5. safari,opera and other

4.Selenium WebDriver的加入环境变量

所有的webdriver需要加入环境变量path中,如果使用python调用,则可以把驱动放在与python.exe相同路径即可。

5.启动RIDE,进行脚本编辑

CMD输入,启动RIDE。再Tools里面点击Creat Desktop 创建桌面快捷方式,下次就可以不需要CMD启动。

ride.py

6.运行脚本测试环境

*** Settings ***
Documentation     this \ is the first test suit
Library           SeleniumLibrary
*** Variables ***
*** Test Cases ***
case1
    [Tags]    test1
    [Setup]    Open chrome
    Maximize Browser Window
    Log    hellow world
    [Teardown]    Close Test

*** Keywords ***
Open chrome
    Open Browser    http://www.baidu.com/    chrome    
    
Close Test
    Capture Page Screenshot
    Close Browser

运行结果pass。

你可能感兴趣的:(selenium,robotFramework)