Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.RuntimeException:无法启动Selenium会话:_Java_Macos_Selenium - Fatal编程技术网

java.lang.RuntimeException:无法启动Selenium会话:

java.lang.RuntimeException:无法启动Selenium会话:,java,macos,selenium,Java,Macos,Selenium,在MacBook Pro中,当我运行以下Selenium时,会出现RuntimeException import com.thoughtworks.selenium.DefaultSelenium; public class Test { public static void main(String[] args) { DefaultSelenium selenium=new DefaultSelenium("localhost", 4444,"*firefox

在MacBook Pro中,当我运行以下Selenium时,会出现RuntimeException

import com.thoughtworks.selenium.DefaultSelenium;

public class Test {

   public static void main(String[] args) {
           DefaultSelenium selenium=new DefaultSelenium("localhost", 4444,"*firefox ","http://");
           selenium.start();
           selenium.open("http://google.co.in");
           selenium.windowMaximize();
           selenium.type("gbqfq", "selenium");
           selenium.click("gbqfb");
   }

}
例外情况:

Exception in thread "main" java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: java.lang.RuntimeException: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3 /blah/blah/firefox-bin
       at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:109)
       at Test.main(Test.java:8)
Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: java.lang.RuntimeException: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3 /blah/blah/firefox-bin
       at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
       at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
       at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:275)
       at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:237)
       at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:100)
       ... 1 more

请帮帮我。。如何解决。

您需要提供firefox配置文件路径,以便selenium可以使用它来实例化浏览器

试试这个:

DefaultSelenium ds=新的DefaultSelenium(新的WebDriverCommandProcessor(“http://:”,新的
FirefoxDriver())

//ds.start();--不要这样做


开放式(“/pdm”)

给出Selenium路径,如下所示:

->DefaultSelenium  selenium = new DefaultSelenium("localhost", 4444, "*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "http://");

为什么不使用
WebDriver
?如果可能,不应再使用Selenium RC(
DefaultSelenium
)。您是否尝试过使用其他Web驱动程序?很明显,selenium无法找到firefox。此外,代码已经过时,请考虑更新它。