发表于: 2019-12-02 23:45:44

1 615


一、今天完成的事情:

1.利用seleniumRC编写自动化测试脚本,然后通过seleniumRC的服务器作为代理服务器去访问应用--https://www.cnblogs.com/cdj811/p/5708861.html

这个教程比较全面,有告诉每一步需要下载的包和软件版本,用错版本极易出错


执行如下代码成功运行,打开百度。因为浏览器版本问题,暂时只用了火狐浏览器

from selenium import selenium
TestSelelium = selenium("localhost""4444""*firefox""https://www.baidu.com")
TestSelelium.start()
TestSelelium.open("")


二、明天计划的事情:

1.继续任务9


三、遇到的问题:

1.selenium RC是什么?--https://www.jianshu.com/p/eb99469a84e1

直到Webdriver/Selenium合并升级到Selenium2之前,Selenium RC一直是Selenium项目的主要工程。

Selenium1仍然被支持(更多的是在维护状态)并且Selenium1能够提供一些Selenium2尚不能支持的一些特殊功能。比如,对大多数编程语言的支持,对大多数浏览器的支持。


Selenium RC组件包含:

Selenium-Core:一段能够利用浏览器的解释器执行Selenium Commands的js代码

Selenium Server启动及关闭浏览器,从测试程序接收Selenium Commands,之后解析Selenium Commands,Selenium Server本身绑定了Selenium Core,且在启动浏览器时将其自动注入(通过client library API启动浏览器)。Selenium Core利用浏览器自带的JavaScrip解析器解析执行Selenium Commands,执行完毕后Selenium Server将执行结果反馈给测试程序。


Selenium Server利用Http Get/Post requests从测试程序中接收Selenium Commands,这意味着,任意支持发送HTTP requests的变成语言都可以用来自动化Selenium tests。


Client libraries为不同编程语言执行Selenium Commands提供了编程接口支持。Client libraries将Selenium Commands发送至Selenium Server,并且接收执行结果反馈给测试程序,测试程序可将执行结果保存到本地变量。基于此,创建一个测试程序,你仅仅需要在测试程序中通过Client library API执行一系列Selenium Commands即可。


2.selenium RC+python使用步骤?--https://blog.csdn.net/weixin_34054931/article/details/92462872

1)下载Selenium RC(下载selenium-server.jar)--http://selenium-release.storage.googleapis.com/index.html

2)下载并安装java

3)启动Selenium Server:java -jar selenium-server.jar

4)在python里安装selenium  pip install -U selenium

5)每个浏览器的调用方法

IE

self.selenium = selenium("localhost", 4444, "*iexplore", "https://www.baidu.com/")

Chrome

self.selenium = selenium("localhost", 4444, "*googlechrome", "https://www.baidu.com/")

firefox

self.selenium =  selenium("localhost", "4444", "*firefox", "https://www.baidu.com")


3.根据from selenium import selenium报错

1)猜测原因是安装的selenium包版本太高

2)使用pip uninstall selenuim卸载selenium-3.141.0

3)找个低版本的selenium带selenium模块的进行安装--https://www.cnblogs.com/cdj811/p/5708861.html

文章中有提到一个低版本:selenium-2.53.6.tar.gz

安装方法:pip install selenium==2.53.6


4.解决完问题3,出现新的问题。--testselenium = selenium("localhost", "4444", "*firefox", "http://www.baidu.com")。。这里的selenium is not callable

from selenium import selenium
import unittest

MAX_WAIT_TIME_IN_MS = 600000
BASE_URL = "http://www.bitmotif.com"

testselenium = selenium("localhost""4444""*firefox""http://www.baidu.com")
selenium.start()

1)猜测是python版本太高。

2)安装python-2.7.11


5.解决完问题4,Selenium RC打开网页失败了

1)猜测浏览器版本不对

2)下载firefox37.0版本--http://ftp.mozilla.org/pub/firefox/releases/


四、收获:

1.了解Selenium RC是什么

2.了解Selenium RC + Python如何使用

3.在不断的出错中明白版本很重要,用错版本甚至会导致想半天都想不到问题在哪里

4.找到一个很好地Selenium RC教程https://www.cnblogs.com/cdj811/p/5708861.html


返回列表 返回列表
评论

    分享到