我正在使用java编写一个带有selenium和phantomjs的自动化程序。起初,我使用firefox进行开发和所有工作。但是,当我将浏览器更改为使用phantomjs时。代码不起作用。在phantomjs中,代码可以帮助用户登录系统,并在登录后页面中单击一个按钮。单击按钮并更改页面后,系统无法在webdriver中获取任何信息(xpath、页面源等)。你能给我一些建议吗?谢谢
错误代码:
2017-08-17 09:31:11.942 ERROR 13120 --- [nio-5566-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: '(HOST-NAME)', ip: '(IP)', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver] with root cause
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[na:1.8.0_131]
at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_131]
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:161) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.execute(PhantomJSCommandExecutor.java:82) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:960) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at bat.service.CommonBcServiceImpl.switchFrame(CommonBcServiceImpl.java:99) ~[main/:na]
at bat.service.CommonBcServiceImpl.loginBcPage(CommonBcServiceImpl.java:60) ~[main/:na]
at bat.service.ServiceControlImpl.createParticipants(ServiceControlImpl.java:50) ~[main/:na]
at bat.controller.ParticipantsController.batNewParticipants(ParticipantsController.java:36) ~[main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[selenium-server-standalone-3.4.0.jar:9.4.3.v20170317]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) [tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.4.jar:8.5.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.4.jar:8.5.4]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
此问题的发生是因为不兼容的版本。
我犯了同样的错误,认为1.9.8是最新版本。从2.1.1更新版本1.9.8后,我的编码工作正常。
更新您的版本,解决您的问题。从下面的链接下载
http://phantomjs.org/download.html
问题内容: 我试图在使用selenium和phantomjs webdriver的linux服务器上运行python脚本;但是,我不断收到以下错误消息: 这是一个失败并生成此错误的简单测试脚本: 在路径上调用文件,返回: 有谁知道如何启动并运行该脚本?我已阅读了似乎类似的stackoverflow问题,并尝试应用建议的解决方案,例如通过npm重新安装幻像并使用sudo执行脚本,但是没有运气。如果我
Selenium Selenium是一个Web的自动化测试工具,最初是为网站自动化测试而开发的,类型像我们玩游戏用的按键精灵,可以按指定的命令自动操作,不同是Selenium 可以直接运行在浏览器上,它支持所有主流的浏览器(包括PhantomJS这些无界面的浏览器)。 Selenium 可以根据我们的指令,让浏览器自动加载页面,获取需要的数据,甚至页面截屏,或者判断网站上某些动作是否发生。 Sel
问题内容: 我已经搜索了解决方案,但没有找到解决方案,但我总是遇到此错误 codigo: 错误: 问题答案: 从下载ChromeDriver http://chromedriver.storage.googleapis.com/index.html?path=2.33/ 此ChromeDriver可以与您的Google Chrome版本一起使用。
问题内容: 建立: selenium :3.141.0 的Python :3.6.7 heroku-stack :heroku-18 headless-chrome :安装了v71.0.3578.80 buildpack chromedriver :已安装v2.44.609551 buildpack 在heroku中使用selenium时出现此错误: 我用谷歌搜索,但是没有运气。错误发生在此代码的
问题内容: 我已经将Docker配置为使用docker-compose.yml运行Postgres和Django,并且工作正常。 我遇到的麻烦是Selenium无法连接到Django liveserver。 现在(至少对我而言),django必须访问selenium才能控制浏览器,而selenium必须访问django才能访问服务器。 我已经尝试从此处使用docker- compose.yml的以
我已经将Docker配置为使用docker-compose.yml运行Postgres和Django,它运行良好。 我遇到的问题是硒无法连接到Django直播服务器。 现在(至少对我来说)django必须访问selenium才能控制浏览器,而selenium必须访问django才能访问服务器。 我尝试使用docker大使模式,使用以下配置从这里docker-compose.yml:https://