osx - Selenium safari driver not working in python -
safari browser gets closed after launching browser
java.util.concurrent.executionexception: org.openqa.selenium.webdriverexception: java.lang.reflect.invocationtargetexception
here env details selenium 2.46. mac os x 10.10.3 x86_64 safari 8.0.5
here sample python code
from selenium import webdriver def test(): driver = webdriver.safari() driver.get("www.google.com")
when run above function, getting following output
15:57:46.465 info - launching standalone selenium server 15:57:46.491 info - java: oracle corporation 24.45-b08 15:57:46.491 info - os: mac os x 10.10.3 x86_64 15:57:46.500 info - v2.46.0, core v2.46.0. built revision 87c69e2 15:57:46.551 info - driver provider org.openqa.selenium.ie.internetexplorerdriver registration skipped: registration capabilities capabilities [{platform=windows, ensurecleansession=true, browsername=internet explorer, version=}] not match current platform mac 15:57:46.552 info - driver class not found: com.opera.core.systems.operadriver 15:57:46.552 info - driver provider com.opera.core.systems.operadriver not registered 15:57:46.603 info - remotewebdriver instances should connect to: http://127.0.0.1:50220/wd/hub 15:57:46.603 info - selenium server , running 15:57:56.500 info - executing: [new session: capabilities [{platform=any, javascriptenabled=true, browsername=safari, version=}]]) 15:57:56.508 info - creating new session capabilities [{platform=any, javascriptenabled=true, browsername=safari, version=}] 15:57:56.561 info - server started on port 39602 15:57:56.570 info - launching safari 15:57:56.579 info - waiting safaridriver connect 15:57:58.044 info - connection opened 15:57:58.046 info - driver connected in 1466 ms 15:57:58.071 info - shutting down 15:57:58.071 info - closing connection 15:57:58.072 info - stopping safari 15:57:58.123 info - stopping server 15:57:58.124 info - stopping server 15:57:58.132 info - shutdown complete 15:57:58.134 warn - exception thrown java.util.concurrent.executionexception: org.openqa.selenium.webdriverexception: java.lang.reflect.invocationtargetexception build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47' system info: host: 'l502062.local', ip: '10.10.80.7', os.name: 'mac os x', os.arch: 'x86_64', os.version: '10.10.3', java.version: '1.7.0_45' driver info: driver.version: unknown @ java.util.concurrent.futuretask.report(futuretask.java:122) @ java.util.concurrent.futuretask.get(futuretask.java:188) @ org.openqa.selenium.remote.server.defaultsession.execute(defaultsession.java:183) @ org.openqa.selenium.remote.server.defaultsession.<init>(defaultsession.java:119) @ org.openqa.selenium.remote.server.defaultsession.createsession(defaultsession.java:95) @ org.openqa.selenium.remote.server.defaultdriversessions.newsession(defaultdriversessions.java:137) @ org.openqa.selenium.remote.server.handler.newsession.handle(newsession.java:58) @ org.openqa.selenium.remote.server.handler.newsession.handle(newsession.java:1) @ org.openqa.selenium.remote.server.rest.resultconfig.handle(resultconfig.java:111) @ org.openqa.selenium.remote.server.jsonhttpcommandhandler.handlerequest(jsonhttpcommandhandler.java:174) @ org.openqa.selenium.remote.server.driverservlet.handlerequest(driverservlet.java:202) @ org.openqa.selenium.remote.server.driverservlet.dopost(driverservlet.java:164) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ org.openqa.selenium.remote.server.driverservlet.service(driverservlet.java:130) @ javax.servlet.http.httpservlet.service(httpservlet.java:820) @ org.openqa.jetty.jetty.servlet.servletholder.handle(servletholder.java:428) @ org.openqa.jetty.jetty.servlet.servlethandler.dispatch(servlethandler.java:680) @ org.openqa.jetty.jetty.servlet.servlethandler.handle(servlethandler.java:571) @ org.openqa.jetty.http.httpcontext.handle(httpcontext.java:1526) @ org.openqa.jetty.http.httpcontext.handle(httpcontext.java:1479) @ org.openqa.jetty.http.httpserver.service(httpserver.java:920) @ org.openqa.jetty.http.httpconnection.service(httpconnection.java:820) @ org.openqa.jetty.http.httpconnection.handlenext(httpconnection.java:986) @ org.openqa.jetty.http.httpconnection.handle(httpconnection.java:837) @ org.openqa.jetty.http.socketlistener.handleconnection(socketlistener.java:243) @ org.openqa.jetty.util.threadedserver.handle(threadedserver.java:358) @ org.openqa.jetty.util.threadpool$poolthread.run(threadpool.java:537) caused by: org.openqa.selenium.webdriverexception: java.lang.reflect.invocationtargetexception build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47' system info: host: 'l502062.local', ip: '10.10.80.7', os.name: 'mac os x', os.arch: 'x86_64', os.version: '10.10.3', java.version: '1.7.0_45' driver info: driver.version: unknown @ org.openqa.selenium.remote.server.defaultdriverprovider.callconstructor(defaultdriverprovider.java:95) @ org.openqa.selenium.remote.server.defaultdriverprovider.newinstance(defaultdriverprovider.java:79) @ org.openqa.selenium.remote.server.defaultdriverfactory.newinstance(defaultdriverfactory.java:62) @ org.openqa.selenium.remote.server.defaultsession$browsercreator.call(defaultsession.java:222) @ org.openqa.selenium.remote.server.defaultsession$browsercreator.call(defaultsession.java:1) @ java.util.concurrent.futuretask.run(futuretask.java:262) @ org.openqa.selenium.remote.server.defaultsession$1.run(defaultsession.java:176) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:744) caused by: java.lang.reflect.invocationtargetexception @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ org.openqa.selenium.remote.server.defaultdriverprovider.callconstructor(defaultdriverprovider.java:85) ... 9 more caused by: org.openqa.selenium.remote.unreachablebrowserexception: not start new session. possible causes invalid address of remote server or browser start-up failure. build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47' system info: host: 'l502062.local', ip: '10.10.80.7', os.name: 'mac os x', os.arch: 'x86_64', os.version: '10.10.3', java.version: '1.7.0_45' driver info: driver.version: safaridriver @ org.openqa.selenium.remote.remotewebdriver.execute(remotewebdriver.java:599) @ org.openqa.selenium.remote.remotewebdriver.startsession(remotewebdriver.java:242) @ org.openqa.selenium.remote.remotewebdriver.<init>(remotewebdriver.java:128) @ org.openqa.selenium.remote.remotewebdriver.<init>(remotewebdriver.java:141) @ org.openqa.selenium.safari.safaridriver.<init>(safaridriver.java:58) @ org.openqa.selenium.safari.safaridriver.<init>(safaridriver.java:51) ... 14 more caused by: java.lang.classcastexception: com.google.gson.jsonobject cannot cast java.lang.string @ org.openqa.selenium.remote.jsontobeanconverter.convert(jsontobeanconverter.java:111) @ org.openqa.selenium.remote.jsontobeanconverter.convert(jsontobeanconverter.java:42) @ org.openqa.selenium.safari.safaridrivercommandexecutor.execute(safaridrivercommandexecutor.java:191) @ org.openqa.selenium.remote.remotewebdriver.execute(remotewebdriver.java:578) ... 19 more 15:57:58.139 warn - exception: com.google.gson.jsonobject cannot cast java.lang.string [ warn ] keyword 'capture page screenshot' not run on failure: cannot access execution context traceback (most recent call last): file "/users/veeraa/documents/workspace/med_selenium/lib/ui/safari_test.py", line 30, in <module> myclass().test() file "<string>", line 2, in test file "/library/python/2.7/site-packages/selenium2library/keywords/keywordgroup.py", line 15, in _run_on_failure_decorator return method(*args, **kwargs) file "/users/veeraa/documents/workspace/med_selenium/lib/ui/safari_test.py", line 26, in test self.driver = webdriver.safari() file "/library/python/2.7/site-packages/selenium/webdriver/safari/webdriver.py", line 62, in __init__ desired_capabilities=desired_capabilities) file "/library/python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 89, in __init__ self.start_session(desired_capabilities, browser_profile) file "/library/python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 138, in start_session 'desiredcapabilities': desired_capabilities, file "/library/python/2.7/site-packages/selenium2library/webdrivermonkeypatches.py", line 11, in execute result = self._base_execute(driver_command, params) file "/library/python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 195, in execute self.error_handler.check_response(response) file "/library/python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 170, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.webdriverexception: message: com.google.gson.jsonobject cannot cast java.lang.string stacktrace: @ org.openqa.selenium.remote.jsontobeanconverter.convert (jsontobeanconverter.java:111) @ org.openqa.selenium.remote.jsontobeanconverter.convert (jsontobeanconverter.java:42) @ org.openqa.selenium.safari.safaridrivercommandexecutor.execute (safaridrivercommandexecutor.java:191) @ org.openqa.selenium.remote.remotewebdriver.execute (remotewebdriver.java:578) @ org.openqa.selenium.remote.remotewebdriver.startsession (remotewebdriver.java:242) @ org.openqa.selenium.remote.remotewebdriver.<init> (remotewebdriver.java:128) @ org.openqa.selenium.remote.remotewebdriver.<init> (remotewebdriver.java:141) @ org.openqa.selenium.safari.safaridriver.<init> (safaridriver.java:58) @ org.openqa.selenium.safari.safaridriver.<init> (safaridriver.java:51) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0 (nativeconstructoraccessorimpl.java:-2) @ sun.reflect.nativeconstructoraccessorimpl.newinstance (nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance (delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance (constructor.java:526) @ org.openqa.selenium.remote.server.defaultdriverprovider.callconstructor (defaultdriverprovider.java:85) @ org.openqa.selenium.remote.server.defaultdriverprovider.newinstance (defaultdriverprovider.java:79) @ org.openqa.selenium.remote.server.defaultdriverfactory.newinstance (defaultdriverfactory.java:62) @ org.openqa.selenium.remote.server.defaultsession$browsercreator.call (defaultsession.java:222) @ org.openqa.selenium.remote.server.defaultsession$browsercreator.call (defaultsession.java:1) @ java.util.concurrent.futuretask.run (futuretask.java:262) @ org.openqa.selenium.remote.server.defaultsession$1.run (defaultsession.java:176) @ java.util.concurrent.threadpoolexecutor.runworker (threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) @ java.lang.thread.run (thread.java:744)
appreciate if can me resolve issue?
thanks much
safari driver version not supported 2.46. try downgrading selenium version:
pip uninstall selenium pip install -iv selenium==2.45 or pip install selenium==2.45
Comments
Post a Comment