Using Python webdriver Remote to connect to the Java Agent for swing

75 views
Skip to first unread message

Martin-Pierre Roy

unread,
Aug 1, 2019, 1:29:20 PM8/1/19
to Marathon Java GUI Testing

Hello,

        Would anyone have experienced connecting the Python remote webdriver with  Java agent for swing. I did run tests that are inconclusive. 


 I this simple Python code :


szURL = "http://127.0.0.1:44444/"

requested_capabilities = {"browserName": "java", "version": "1.0", "platform": "ANY"}

driver = webdriver.Remote(command_executor=szURL, desired_capabilities=requested_capabilities)

title = driver.title

print(f'Window title is {title}')

driver.quit()


The  result is the following:

Traceback (most recent call last):

  File "/home/ur/dev/pycharm/helpers/pydev/pydevd.py", line 2060, in <module>

    main()

  File "/home/ur/dev/pycharm/helpers/pydev/pydevd.py", line 2054, in main

    globals = debugger.run(setup['file'], None, None, is_module)

  File "/home/ur/dev/pycharm/helpers/pydev/pydevd.py", line 1405, in run

    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)

  File "/home/ur/dev/pycharm/helpers/pydev/pydevd.py", line 1412, in _exec

    pydev_imports.execfile(file, globals, locals)  # execute the script

  File "/home/ur/dev/pycharm/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile

    exec(compile(contents+"\n", file, 'exec'), glob, loc)

  File "/home/ur/PycharmProjects/pyjavadriverfw/scripts/DemoRQ.py", line 27, in <module>

    demo.java_driver_demo()

  File "/home/ur/PycharmProjects/pyjavadriverfw/scripts/DemoRQ.py", line 11, in java_driver_demo

    driver = webdriver.Remote(command_executor=szURL, desired_capabilities=requested_capabilities)

  File "/home/ur/PycharmProjects/pyjavadriverfw/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__

    self.start_session(capabilities, browser_profile)

  File "/home/ur/PycharmProjects/pyjavadriverfw/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session

    response = self.execute(Command.NEW_SESSION, parameters)

  File "/home/ur/PycharmProjects/pyjavadriverfw/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute

    self.error_handler.check_response(response)

  File "/home/ur/PycharmProjects/pyjavadriverfw/venv/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 208, in check_response

    raise exception_class(value)

selenium.common.exceptions.WebDriverException: Message: Not Implemented: (route is null)



On the server side I get this in the console

Aug 01, 2019 5:02:49 PM net.sourceforge.marathon.javaagent.server.JavaServer serve

INFO: JavaServer.serve(POST //session): {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "java", "browserVersion": "1.0", "platformName": "any"}}, "desiredCapabilities": {"browserName": "java", "version": "1.0", "platform": "ANY"}}

Aug 01, 2019 5:02:49 PM net.sourceforge.marathon.javaagent.server.JavaServer serve

INFO: POST(//session, {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"browserVersion":"1.0","browserName":"java","platformName":"any"}},"desiredCapabilities":{"browserName":"java","version":"1.0","platform":"ANY"}}) = {data=Not Implemented: (route is null), status=NOT_FOUND}


   I ran my Python test using the selenium wheel version selenium-3.141.0, but I also ran the test using version 3.8.0, 3.12.0 and the latest 4.0.0a1 with the same result.



I have the equivalent code running in Java and it runs flawlessly.


try {
   
String szURL = "http://127.0.0.1:44444";
   
RemoteWebDriver driver = new RemoteWebDriver(
           
new URL(szURL),
           
new DesiredCapabilities("java", "1.0", Platform.ANY)
   
);
   
String title = driver.getTitle();
   
System.out.println("Window title is " + title);
    driver
.quit();
} catch(Exception exp){
   
System.out.println("Exception occurred while connecting to JavaDriver [ " + exp.getMessage() + " ]");
}


Many thanks for your help,

MP

Aditya Chandrasekhar Karra

unread,
Aug 2, 2019, 7:16:04 AM8/2/19
to Marathon Java GUI Testing
Hi Martin

We have tried with selenium version '3.13.0' and it worked. Currently marathon doesn't support w3c so the newer versions of selenium won't work.
Please check the url you have given in the python remote WebDriver.


from selenium import webdriver


caps = {"browserName": "java", "version": "1.0", "platform": "ANY"}


driver = webdriver.Remote(command_executor="http://127.0.0.1:53611", desired_capabilities=caps)

print(driver.current_url)



Thanks & Regards

Aditya Karra

Martin-Pierre Roy

unread,
Aug 6, 2019, 9:19:24 AM8/6/19
to marathon...@googlegroups.com

When you say that the project does not support the W3C specification are we talking momentarily the time to implement the up-to-date specification or rather the project Marathon will distance itself from the W3C WebDriver specification?

Thanks,
MP
Reply all
Reply to author
Forward
0 new messages