在 FirefoxDriver 上打开 URL 失败,并出现 WebDriverException: 无法解析“”

发布于 2024-08-26 07:15:54 字数 3571 浏览 13 评论 0原文

我正在使用 Selenium Webdriver 进行一些机器人测试。由于某些功能似乎只能在 Firefox 中使用,因此我不得不使用 Firefoxdriver。 时不时地,会发生一些奇怪的事情。启动驱动程序

driver = new FirefoxDriver();
driver.get(URL);

会使 Firefox 启动,但不会转到指定的 url。奇怪的是,它可以在另一台具有 Firefox 中设置的相同首选项的计算机上运行。我曾经通过更改为另一个版本的 Firefox 解决了这个问题,但这一次这对我来说不起作用,但它对其他开发人员有用。是的,所有开发人员在同一天同一时间开始出现错误...... 我的第一个问题是:这是 firefox 问题还是 Webdriver 问题。 第二个问题:它怎么可能在其他电脑上运行?

任何帮助将不胜感激 谢谢

Error:

org.openqa.selenium.WebDriverException: Could not parse "".
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_18'
Driver info: driver.version: firefox
    at org.openqa.selenium.firefox.Response.<init>(Response.java:53)
    at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.nextResponse(AbstractExtensionConnection.java:258)
    at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.readLoop(AbstractExtensionConnection.java:220)
    at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.waitForResponseFor(AbstractExtensionConnection.java:213)
    at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.sendMessageAndWaitForResponse(AbstractExtensionConnection.java:162)
    at org.openqa.selenium.firefox.FirefoxDriver.executeCommand(FirefoxDriver.java:329)
    at org.openqa.selenium.firefox.FirefoxDriver.sendMessage(FirefoxDriver.java:312)
    at org.openqa.selenium.firefox.FirefoxDriver.sendMessage(FirefoxDriver.java:308)
    at org.openqa.selenium.firefox.FirefoxDriver.fixId(FirefoxDriver.java:350)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:130)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:109)
    at be.....MMCRobotTest.login(MMCRobotTest.java:98)
    at be.....MMCRobotTestAttribute.testNewAttribute(MMCRobotTestAttribute.java:12)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.json.JSONException: A JSONObject text must begin with '{' at character 0
    at org.json.JSONTokener.syntaxError(JSONTokener.java:496)
    at org.json.JSONObject.<init>(JSONObject.java:180)
    at org.json.JSONObject.<init>(JSONObject.java:403)
    at org.openqa.selenium.firefox.Response.<init>(Response.java:41)
    ... 30 more

I'm using Selenium Webdriver to do some robottesting. Since some functions appear to only work in Firefox, I'm obligated to use Firefoxdriver.
Now and then, something weird happens. Starting up te driver

driver = new FirefoxDriver();
driver.get(URL);

gets firefox to startup but not to go to the specified url. The strange thing is that it works on another computer with the same preferences set in Firefox. I solved this problem once by changing to another version of firefox, but this time this doesn't do the trick for me, it did however worked for the other developers. Yes, the error started for all developers on the same time, same day...
My first question is: is it a firefox problem or Webdriver problem.
Second question: how is it possible that it works on other pc's?

Any help would be very appreciated
Thanks

Error:

org.openqa.selenium.WebDriverException: Could not parse "".
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_18'
Driver info: driver.version: firefox
    at org.openqa.selenium.firefox.Response.<init>(Response.java:53)
    at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.nextResponse(AbstractExtensionConnection.java:258)
    at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.readLoop(AbstractExtensionConnection.java:220)
    at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.waitForResponseFor(AbstractExtensionConnection.java:213)
    at org.openqa.selenium.firefox.internal.AbstractExtensionConnection.sendMessageAndWaitForResponse(AbstractExtensionConnection.java:162)
    at org.openqa.selenium.firefox.FirefoxDriver.executeCommand(FirefoxDriver.java:329)
    at org.openqa.selenium.firefox.FirefoxDriver.sendMessage(FirefoxDriver.java:312)
    at org.openqa.selenium.firefox.FirefoxDriver.sendMessage(FirefoxDriver.java:308)
    at org.openqa.selenium.firefox.FirefoxDriver.fixId(FirefoxDriver.java:350)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:130)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:109)
    at be.....MMCRobotTest.login(MMCRobotTest.java:98)
    at be.....MMCRobotTestAttribute.testNewAttribute(MMCRobotTestAttribute.java:12)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.json.JSONException: A JSONObject text must begin with '{' at character 0
    at org.json.JSONTokener.syntaxError(JSONTokener.java:496)
    at org.json.JSONObject.<init>(JSONObject.java:180)
    at org.json.JSONObject.<init>(JSONObject.java:403)
    at org.openqa.selenium.firefox.Response.<init>(Response.java:41)
    ... 30 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丶视觉 2024-09-02 07:15:54

我建议您使用最新版本的 Firefox 浏览器和最新的 selenium 服务器库。
或者我认为您忘记在出现问题的一台机器上包含所有 lib jar。

I suggest you to use latest version of Firefox browser with latest selenium server libraries.
Or I think you forgot to include all lib jars on one machine where you are getting problem.

嘴硬脾气大 2024-09-02 07:15:54

确保 URL 以正确的协议为前缀,例如“http://”。删除它会产生异常,添加它会阻止它。

Make sure that the url is prefixed with the proper protocol like 'http://'. Removing this gave that exception and adding this prevented it.

弱骨蛰伏 2024-09-02 07:15:54

我认为您已经安装了多个版本的 Firefox 浏览器,
尝试卸载所有并安装最新版本...
希望这有帮助..

I think you've installed multiple versions of Firefox browsers,
try uninstalling all and install the latest version...
Hope this helps..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文