selenium学习中遇到的问题
来源:互联网 发布:江恩四方形软件下载 编辑:程序博客网 时间:2024/05/22 17:07
1. Selenium IDE, Options > Format 选择Java / Junit 4 / Remote Control, 录制的Source代码仍旧不是Junit4的代码。
解决:打开IDE Options > Options, 选上Enable experimental features, 再设置Options > Format, 就可以得到Junit代码。
可通过文件 > Export Test Case As... > Java / Junit4 / Remote Control 保存得到代码。
2. 引入架包seleniumserver.jar 和 selenium-java-client-driver.jar架包之后,selenium字仍显示红杠杠。
解决:代码内加上定义selenium语句:
private
static
DefaultSelenium selenium;
3. java.lang.RuntimeException: Could not contact Selenium Server; have you started it on 'localhost:4444' ?
Read more at http://seleniumhq.org/projects/remote-control/not-started.html
Connection refused: connect
解决:Selenium RC未启动,启动即可。
java -jar selenium-server-standalone-2.25.0.jar
4. 不启动cmd运行selenium rc, 直接Java启动的方法。
解决:使用java代码如下
SeleniumServer SELENIUM_SERVER;
@Before
public
void
setUp()
throws
Exception {
RemoteControlConfiguration rcc =
new
RemoteControlConfiguration();
rcc.setPort(
4444
);
//指定selenium server 开放端口
SELENIUM_SERVER =
new
SeleniumServer(rcc);
SELENIUM_SERVER.start();
//测试前启动server
}
@After
public
void
tearDown()
throws
Exception {
SELENIUM_SERVER.stop();
//测试结束停止server
}
5. 运行时出现错误WARNING: Failed to start: SocketListener0@0.0.0.0:4444
解决:出现这错误表示已经有另外一个Selenium server 启动了,可以通过ps -efa | grep selenium查看是否有其他的selenium server正在运行, 如果有请将其关闭即可;否则就是有另外的服务器在使用4444端口,需要更换端口。
6. java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox.exe'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3 c:\blah\firefox.exe
解决:网上提供方法一是:我的电脑-属性-高级-环境变量-系统变量-PATH
PATH=$PATH;D:\Program Files\Mozilla Firefox\
需要重新启动一次eclipse
这个我试了无效,不知道怎么回事,怀疑是跟Selenium-server.jar包和Firefox版本不一致有关。
试验成功的方法是:在代码里面加上安装路径,可能是因为selenium server只能识别C盘, 不能识别其它盘,而Firefox我装在D盘的,所以我就加上路径,再启动服务进行运行,成功。
selenium = new DefaultSelenium(“localhost”, 4444, “*firefox D:/Program Files/Mozilla Firefox/firefox.exe”, “http://www.baidu.
PS:首先一开始要注意Selenium server有没有启动,使用 java -jarE:\BaiduNetdiskDownload\selenium-2.42.2\selenium-server-standalone-2.44.0.jar命令启动,全部是started的时候才说明启动成功
其次,要配置firefox的环境变量路径
最后,用SeleniumIED录制脚本后,导入elipse中事,要注意firefox的路径有没有正确。
- selenium学习中遇到的问题
- selenium学习中遇到的问题
- 学习selenium + Python 遇到的问题
- selenium使用中遇到的问题
- selenium使用中遇到的问题
- selenium使用过程中遇到的问题
- selenium使用中遇到的问题
- selenium遇到的问题
- [Selenium] Selenium RC二次开发遇到的问题
- Python+Selenium学习遇到的问题总结(一)
- 使用selenium遇到的问题
- selenium python 遇到的问题
- Python+Selenium遇到的问题
- selenium使用遇到的问题
- selenium 所遇到的问题
- 安装selenium遇到的问题
- Ruby selenium-client 使用中遇到的问题
- selenium+python 中遇到的编解码问题
- 在网上查找到的单链表试题
- 设计模式19-备忘录模式
- okhttp缓存
- printf,sprintf,vsprintf 区别
- GKShuffledDistribution
- selenium学习中遇到的问题
- pom.xml build src文件夹设置
- Java问题收录
- 我的安卓手机上的垃圾文件清理记录
- dao 接口定义了一个方法,报错 The method xxx is undefined for the type xxx;
- sja1000调试经验
- 在SpringMVC中使用Redis的简单实例
- iPhone X的简单适配
- HTML5宏观概览、新增特性一览