在eclipse中创建java工程用于运行java语言的selenium脚本
使用火狐的 selenium ide录制http://newtours.demoaut.com/网站的预定机票的脚本,文件-》export Test Case as 选择java/Junit4/Remote Control 保存为java格式的文件
将文件之间Ctrl+V复制到工程中,这个时候直接运行会报
java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Error while launching browser
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:100)
...................
解决方式:
默认是使用"*chrome", 浏览器运行,但是我没有装该浏览器,使用火狐java也会阻止该程序打开新页面
所以我将运行脚本的浏览器设置成ie,虽然也会阻止但是很够打开了(修改java怕会影响电脑的安全性)
将selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://newtours.demoaut.com/");
修改为
selenium = new DefaultSelenium("localhost", 4444, "iexplore", "http://newtours.demoaut.com/");
使用火狐的 selenium ide录制http://newtours.demoaut.com/网站的预定机票的脚本,文件-》export Test Case as 选择java/Junit4/Remote Control 保存为java格式的文件
将文件之间Ctrl+V复制到工程中,这个时候直接运行会报
java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Error while launching browser
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:100)
...................
解决方式:
默认是使用"*chrome", 浏览器运行,但是我没有装该浏览器,使用火狐java也会阻止该程序打开新页面
所以我将运行脚本的浏览器设置成ie,虽然也会阻止但是很够打开了(修改java怕会影响电脑的安全性)
将selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://newtours.demoaut.com/");
修改为
selenium = new DefaultSelenium("localhost", 4444, "iexplore", "http://newtours.demoaut.com/");
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25550578/viewspace-1398177/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25550578/viewspace-1398177/