java-org.openqa.selenium.UnsupportedCommandException:使用Selenium找不到变量资源
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-org.openqa.selenium.UnsupportedCommandException:使用Selenium找不到变量资源,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2750字,纯文字阅读大概需要4分钟。
内容图文
![java-org.openqa.selenium.UnsupportedCommandException:使用Selenium找不到变量资源](/upload/InfoBanner/zyjiaocheng/651/3f97052cfae6438ca4571193d5d2e87b.jpg)
我正在使用使用硒协议的phantomjs webdriver渲染网页.当我尝试渲染网页时,出现以下错误
RemoteWebDriver.get(url)
尽管我的webdriver正在运行.
我也尝试过重新启动phantomjs webdriver.
org.openqa.selenium.UnsupportedCommandException: Variable Resource Not Found - {"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"39","Content-Type":"application/json; charset=utf-8","Host":"10.20.1.239:9517","User-Agent":"Apache-HttpClient/4.5.5 (Java/1.8.0_171)"},"httpVersion":"1.1","method":"POST","post":"{\"url\":\"http://example.com/\"}","url":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/url","urlParsed":{"anchor":"","query":"","file":"url","directory":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/","path":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/url","relative":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/url","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/url","queryKey":{},"chunks":["session","07e53c90-6b45-11e9-892c-4faf7180871b","url"]}}
Command duration or timeout: 10.20 seconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'ip-10-20-1-73.ec2.internal', ip: '10.20.1.73', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.2.3.el7.x86_64', java.version: '1.8.0_171'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=2.1.1, platform=LINUX, browserConnectionEnabled=false, proxy=Proxy(direct), nativeEvents=true, acceptSslCerts=false, driverVersion=1.2.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 07e53c90-6b45-11e9-892c-4faf7180871b
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_171]
at
解决方法:
RemoteWebDriver是关键字/保留的单词.因此,RemoteWebDriver实例的名称应不同.此外,在调用RemoteWebDriver时,您需要传递Selenium Grid Hub的URL和DesiredCapabilities实例作为强制参数,并且可以使用以下(基于Windows)解决方案:
File path=new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path",path.getAbsolutePath());
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setPlatform(Platform.XXX);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
driver.get("https://www.google.co.in");
System.out.println(driver.getTitle());
driver.quit();
内容总结
以上是互联网集市为您收集整理的java-org.openqa.selenium.UnsupportedCommandException:使用Selenium找不到变量资源全部内容,希望文章能够帮你解决java-org.openqa.selenium.UnsupportedCommandException:使用Selenium找不到变量资源所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。