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

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

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. Firfox在这里插入图片描述
  2. Chrome
    在这里插入图片描述
    驱动下载地址
  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。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值