在robotframework中,使用selenium库,无头模式

目前使用python2.7(请勿鄙视,公司环境,无法使用python3)+ robot framework,做功能测试的自动化。 今天需要使用selenium进行web页面的操作,记录如下

 

安装selenium2Library库

使用pip安装,过程是简单: pip install robotframework-selenium2Library

 

无头模式

其他的使用方式这里就不说了,只说怎么实现浏览器的无头模式

常用的Open Browser关键字,无法在本地实现无头模式(如果有错误,请指出),因为其最终调用的函数是

    def _make_ff(self , remote , desired_capabilites , profile_dir):

        if not profile_dir: profile_dir = FIREFOX_PROFILE_DIR
        profile = webdriver.FirefoxProfile(profile_dir)
        if remote:
            browser = self._create_remote_web_driver(webdriver.DesiredCapabilities.FIREFOX  ,
                        remote , desired_capabilites , profile)
        else:
            browser = webdriver.Firefox(firefox_profile=profile)
        return browser

我们可以看到,对于本地浏览器来说,创建Firefox实例时,仅用了profile参数,无法将无头参数传入,因为无头参数需要在options或者firefox_options参数中传入。可以看下面Firefox对象的__init__函数:

<
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值