所以(在我不断尝试成为Haskell程序员的尝试中)我想我会尝试使用Haskell在Mac上自动控制Firefox。去了https://github.com/kallisti-dev/hs-webdriver,安装了webdriver,安装了独立的java selenium服务器并尝试运行简单的Hello World测试(在修复语法错误之后,runSession的' config'参数应该是(我假设) '的myconfig&#39)
看着Firefox开了片刻,然后就消失了。基于Java的selenium服务器产生了大量的错误消息。见下文。任何人都知道什么是错的?
为了它的价值,在尝试之后,我安装了python绑定并且有一个python版本在大约10秒内工作!
dhjmacpro:~/bin $ java -jar selenium-server-standalone-2.42.2.jar
Jul 25, 2014 12:32:28 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
12:32:28.052 INFO - Java: Apple Inc. 20.65-b04-462
12:32:28.053 INFO - OS: Mac OS X 10.9.4 x86_64
12:32:28.061 INFO - v2.42.2, with Core v2.42.2. Built from revision 6a6995d
12:32:28.125 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: MAC
12:32:28.153 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
12:32:28.154 INFO - Version Jetty/5.1.x
12:32:28.154 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
12:32:28.155 INFO - Started HttpContext[/selenium-server,/selenium-server]
12:32:28.155 INFO - Started HttpContext[/,/]
12:32:28.185 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@3dbbd23f
12:32:28.185 INFO - Started HttpContext[/wd,/wd]
12:32:28.190 INFO - Started SocketListener on 0.0.0.0:4444
12:32:28.190 INFO - Started org.openqa.jetty.jetty.Server@4ca31e1b
12:32:55.022 INFO - Executing: [new session: Capabilities [{platform=ANY, javascriptEnabled=null, acceptSslCerts=null, firefox_binary=null, browserName=firefox, rotatable=null, locationContextEnabled=null, unexpectedAlertBehavior=null, version=null, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@45490eb5, firefox_profile=null, databaseEnabled=null, cssSelectorsEnabled=null, handlesAlerts=null, browserConnectionEnabled=null, proxy={proxyType=SYSTEM}, webStorageEnabled=null, nativeEvents=null, applicationCacheEnabled=null, takesScreenshot=null}]])
12:32:55.038 INFO - Creating a new session for Capabilities [{platform=ANY, javascriptEnabled=null, acceptSslCerts=null, firefox_binary=null, browserName=firefox, rotatable=null, locationContextEnabled=null, unexpectedAlertBehavior=null, version=null, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@45490eb5, firefox_profile=null, databaseEnabled=null, cssSelectorsEnabled=null, handlesAlerts=null, browserConnectionEnabled=null, proxy={proxyType=SYSTEM}, webStorageEnabled=null, nativeEvents=null, applicationCacheEnabled=null, takesScreenshot=null}]
12:32:57.851 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'dhjmacpro', ip: '192.168.0.45', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.6.0_65'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:176)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:112)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:89)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:110)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:57)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:112)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:173)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:200)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:128)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'dhjmacpro', ip: '192.168.0.45', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.6.0_65'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:69)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:53)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:54)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:215)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:59)
... 10 more
Caused by: org.openqa.selenium.WebDriverException: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIPrefBranch.setCharPref]
Command duration or timeout: 181 milliseconds
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'dhjmacpro', ip: '192.168.0.45', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.6.0_65'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
... 15 more
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIPrefBranch.setCharPref]
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'dhjmacpro', ip: '192.168.0.45', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.6.0_65'
Driver info: driver.version: unknown
12:32:57.857 WARN - Exception: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIPrefBranch.setCharPref]
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'dhjmacpro', ip: '192.168.0.45', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.6.0_65'
Driver info: driver.version: unknown
答案 0 :(得分:2)
好的,似乎图书馆在大约一年内没有更新,但这是我的建议:
从那里你应该可以启动并运行测试。我知道我已经在我的机器上成功运行了。如果您对此方法有更多疑问,请询问。