【问题标题】:java.io.FileNotFoundException when trying to run script with Selenium尝试使用 Selenium 运行脚本时出现 java.io.FileNotFoundException
【发布时间】:2016-01-25 17:40:59
【问题描述】:

当我尝试使用 selenium 运行脚本时,出现以下错误

线程“主”org.openqa.selenium.WebDriverException 中的异常: java.io.FileNotFoundException: D:\Shantu!!!!!!! (系统不能 找到指定的文件)构建信息:版本:'2.49.1',修订: '7203e46',时间:'2016-01-21 17:35:35' 系统信息:主机: 'ghijkl-ab562296',ip:'192.168.43.128',os.name:'Windows XP', os.arch: 'x86', os.version: '5.1',​​ java.version: '1.8.0_40' 驱动 信息:driver.version:FirefoxDriver 在 org.openqa.selenium.firefox.FirefoxProfile.onlyOverrideThisIfYouKnowWhatYouAreDoing(FirefoxProfile.java:132) 在 org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:85) 在 org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:78) 在 org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:67) 在 org.openqa.selenium.firefox.FirefoxDriver.getProfile(FirefoxDriver.java:288) 在 org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:264) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:119) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:218) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:207) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) 在 practicePackage.New.main(New.java:11) 引起: java.io.FileNotFoundException: D:\Shantu!!!!!!! (系统不能 在 java.util.zip.ZipFile.open(Native Method) 处找到指定的文件 在 java.util.zip.ZipFile.(Unknown Source) 在 java.util.zip.ZipFile.(未知来源)在 java.util.jar.JarFile.(未知来源)在 java.util.jar.JarFile.(未知来源)在 sun.net.www.protocol.jar.URLJarFile.(Unknown Source) at sun.net.www.protocol.jar.URLJarFile.getJarFile(未知来源)在 sun.net.www.protocol.jar.JarFileFactory.get(未知来源)在 sun.net.www.protocol.jar.JarURLConnection.connect(未知来源)在 sun.net.www.protocol.jar.JarURLConnection.getInputStream(未知 源)在 java.net.URL.openStream(未知源)在 org.openqa.selenium.firefox.FirefoxProfile.onlyOverrideThisIfYouKnowWhatYouAreDoing(FirefoxProfile.java:130) ... 11 更多

【问题讨论】:

  • 请提供代码..
  • 请在package practicePackage下面找到代码;导入 org.openqa.selenium.WebDriver;导入 org.openqa.selenium.firefox.FirefoxDriver; public class New { public static void main(String[] args) { // TODO 自动生成的方法存根 WebDriver driver = new FirefoxDriver(); driver.get("google.co.in/…); } }
  • 请检查答案..谢谢

标签: java selenium-webdriver


【解决方案1】:

当您尝试使用您创建的特定 firefox 配置文件测试应用程序时,似乎引发了异常。

【讨论】:

  • 你能指导我如何知道我是否创建了 Firefox 配置文件。谢谢 Shantaveer B
  • 虽然看起来你调用了new FirefoxDriver(),但我猜你也将webdriver.firefox.profile系统属性设置为指向D:\Shantu!!!!!!!。由于那里没有有效的配置文件,只需删除该属性,浏览器就会在启动时选择默认配置文件。
【解决方案2】:

在尝试获取任何 URL 时,我们需要提供完整的 URL 方式,包括 http://...

    WebDriver driver=new FirefoxDriver();
    driver.get("http://www.google.com");

你可以试试这样吗。

谢谢你, 壁画

【讨论】:

  • 我尝试了同样的方法,但我仍然面临同样的异常感谢 Shantaveer B
  • 火狐是什么版本的?浏览器正在启动吗?
  • 还有一件事是请检查firefox是否安装在默认位置,即程序文件
  • 火狐版本是43.0.4
  • 浏览器是否正在开始执行?
猜你喜欢
  • 2019-05-12
  • 1970-01-01
  • 2023-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-22
  • 2022-10-08
  • 1970-01-01
相关资源
最近更新 更多