Selnium1中以未在默认目录安装的firefox为启动浏览器
OS version:Win7 64bit
当firefox没有安装在默认目录下,selenium1找不到它。如果用以下code
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://xxx.com/");
会有以下错误:
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
解决方法1:添加firefox.exe所在文件目录的完整路径到环境变量PATH中。
解决方法2:将以上code中“*firefox”改为"*firefox[1空格]%安装路径%\firefox.exe"
你认为这样就大功告成了吗?
看,你傻傻的按照它的提示写成"*firefox F:\Program Files (x86)\Mozilla Firefox\firefox.exe",结果又说是应该按照转义字符的写法书写。别晕,老老实实的按照提示做,写成"*firefox F:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"或
"*firefox F:/Program Files (x86)/Mozilla Firefox/firefox.exe"
就此才真的大功告成。