幻像未为可执行文件路径设置正确的所需功能



我正在尝试为我的可执行 phantomjs 设置路径.exe在 webDriver 的 DesiredCapabilities 对象中。但是,它正在为指定的路径添加额外的路径。我想它从我的系统中获取它,但如何防止它这样做。代码给出如下:

DesiredCapabilities DesireCaps = new DesiredCapabilities();
DesireCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,"C:Userssu.tDesktopphantomjs-2.1.1-linux-x86_64binphantomjs");
System.out.println(DesireCaps.getCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY));
WebDriver driver = new PhantomJSDriver(DesireCaps);

这将引发以下错误: java.lang.IllegalStateException:驱动程序可执行文件不存在:**/home/niti.j/**C:Userssu.tDesktopphantomjs-2.1.1-linux-x86_64binphantomjs

以粗体显示的路径会自动添加到指定的路径中。请让我知道如何防止这种情况 幻影js驱动程序版本:1.2.1

庞.xml

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.53.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-htmlunit-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/dom4j/dom4j -->
<!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.53.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-exec -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>1.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.53.0</version>
</dependency> 

指定的路径可能存在一些问题。仔细检查路径和路径应该是包含驱动程序的文件夹,而不是驱动程序本身。

所以 在您的这个位置: C:\Users\su.t\Desktop\phantomjs-2.1.1-linux-x86_64\bin\phantomjs

Phantomjs 应该是包含 Phantomjs 驱动程序的文件夹。如果这个 phantomjs 在 bin 文件夹中,请创建您的路径: C:\Users\su.t\Desktop\phantomjs-2.1.1-linux-x86_64\bin

相关内容

  • 没有找到相关文章

最新更新