SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

Getting error "Unable to find a matching set of capabilities" when I try to launch safari browser on iPhone.

Open mshariqa opened this issue 2 years ago • 5 comments

For issues

We have recently started automating iPhone safari with robot framework selenium. Sometimes we get "Unable to find a matching set of capabilities" when we try to run iPhone safari. I searched online but could not find any issue like this. I feel there is some capabilities I am missing but similar capabilities is working when I used python language binding. Please help.

Steps to reproduce the issue

${capabilities}= Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.SAFARI sys, selenium.webdriver

Set To Dictionary ${capabilities} platformName=ios Set to Dictionary ${capabilities} browserName=safari Log To Console ${capabilities}

Open Browser url=https://www.google.com desired_capabilities=${capabilities} remote_url=http://localhost:4449/wd/hub

Error messages and additional information

Robot Framework logs: SessionNotCreatedException: Message: Unable to find a matching set of capabilities Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'P84445', ip: 'fe80:0:0:0:1832:dbdf:a8c:c83b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '12.4', java.version: '11.0.15' Driver info: driver.version: unknown remote stacktrace: Stacktrace: at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2) at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62) at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance (Constructor.java:490) at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0 (W3CHandshakeResponse.java:62) at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0 (HandshakeResponse.java:30) [ Message content over the limit has been removed. ] at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474) at java.util.stream.FindOps$FindOp.evaluateSequential (FindOps.java:150) at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:543) at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession (NewSessionPipeline.java:72) at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute (BeginSession.java:65) at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0 (WebDriverServlet.java:235) at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:515) at java.util.concurrent.FutureTask.run (FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628) at java.lang.Thread.run (Thread.java:829)

Selenium Grid logs: 17:33:12.151 DEBUG [WebDriverServlet.handle] - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@64a951bc 17:33:12.155 DEBUG [WebDriverServlet.lambda$handle$0] - /session: Executing POST on /session (handler: BeginSession) 17:33:12.205 INFO [ActiveSessionFactory.apply] - Capabilities are: { "browserName": "safari", "moz:firefoxOptions": { "profile": "UEsDBBQAAAAIACaM3VTrmRmacgMAAJoMAAAHAAAAdXNlci5qc6VWTW\u002fUMBC98ytQTyCx1rbABU6lFAkJUcSq4mg59mTjrmMbe7zp\u002fnvGyaYsbb6AWz7e89hvZt44RQjcByhfnBXBNfTGlKtZo61yDVOp9gysKAyos1fPMSR4+f5ZesoxAiGEZE\u002fApTBxBG2hQVGwFAzhzkThEr4rjLC7sym8F1tYtn5EETB5lhmEXE+jKlfDEblgL49Z3O3p5FoBqyM6266it9YFGFmAPqkb+6MVOJ6vmbYY3O33L9Phc1Jqcc9lFSgwjzJoj5wU56jrHPT1epiwDBnAu4BcGMPvIod7CR61s3Ew6XdiL7plmetgLFau+Wyv6NEZGCRZwMaFHZOCKHtY5XjCrAiw13ImrxFkChoPTMa+HEeAj5PTgJFZr9lSm2IyoZTO5xQzizRQqECHC1zIrCBPlNsUERSXEHBYzRNSjClHfCBp+gBhkCW8Z8krajsmErphOU5Ai\u002fpG6eiNOIC6Pl9vvjqkxBDhzQjYNdY4oajKLAkW2hr4UYHdZCm13U7Hur79csn63pn0lhb5mnWSzvmQtjsqSrBUw+RIXcYu5rDkL53hjYNdWRJ+pOx6UAChsjKAIGmnn3SIeElayJGeePAUUUL7TKotdLhTRi1MI8JSbwQRZHUsizmoKWPyuVN7rx4zRYgx+wCS7ZEKbRmXZFRcBhGrmSgVGMNkBXL3EUqRDH7o\u002fkzTaCBERse2N\u002fbKuDhzlBP0DWV8GEyKiM4Is6oVCINV984W2dQEP\u002fncKtf\u002fyO6jl7mgvqe\u002f375x223+KDuD\u002fot9eGe0PLD8cZOKWrd5\u002fl\u002f+t\u002fbj5e+GHloG9uiciYwcwoXjxifvInmOkYNlAG\u002fbWtHQsFuelR+OkT3CtoXbmujHjryRxM5efb4ehRfGyZ3REacr4oTRFviVq71AXWiTp5nV2wrNYZa6xMKfwi35d3m4HW2kkyk+pWo\u002ftzuXXx19cEXzElMcXrmnVIh0B6t0rA6r\u002fNvTgFsZsFvMlnDx9u2ftH5pmlqUD2Ncw4sDV50nDO7Nk8V4jLm7ee2UMAuvEaU2QE\u002fMBU1twbsazTejGXzEoCXyx7ShUPkKaMkKa6gLCJv2dUSuXOY7jewoWz9Oj6U8ePCegmAoAoYD66RoT34xh50U6Sk8wF07zgZ3cu812T5li+UjU02Q+xPjZ9JhLMJvSlNpCpO7aIDxC1BLAQIUAxQAAAAIACaM3VTrmRmacgMAAJoMAAAHAAAAAAAAAAAAAACkgQAAAAB1c2VyLmpzUEsFBgAAAAABAAEANQAAAJcDAAAAAA==" }, "platformName": "ios" } 17:33:12.207 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService) 1656491592225 geckodriver INFO Listening on 127.0.0.1:7741

Expected behavior and actual behavior

When I try to run open browser for safari iphone no matter what I do I am not able to launch the browser.

I can run the similar code when I use python binding with same capabilities.

` from selenium import webdriver

caps = {'browserName': 'safari', 'platformName': 'ios'} driver = webdriver.Remote('http://localhost:4449/wd/hub', desired_capabilities=caps) driver.get('http://www.google.com') `

Environment

Browser: iOS Version 14.6 Browser driver: Safari 15.5 (17613.2.7.1.8) Operating System: Mac

Libraries

  • Robot Framework: 5.0.1
  • Selenium: 4.3.0
  • SeleniumLibrary: 6.0.0
  • Interpreter: pipenv
  • Selenium Grid: 3.141.59

mshariqa avatar Jun 29 '22 09:06 mshariqa

I've not used Selenium Grid much at all and unfamiliar with functionality within ver 3.141.59 but desired_capabilities was dropped in support of using options in Selenium 4.3.0. SeleniumLibrary, as I recall, still has them although they should be depreciated and removed. I'm not sure how it is working with the python but given what you share with environment settings I would expect issues.

See Python Release notes (for 4.1.4).

Note support questions like these are best asked in one of the community resources - Slack, Forum (prefered) or Email list.

emanlove avatar Jun 29 '22 13:06 emanlove

Hi @emanlove, Thanks for your suggestion. I will keep in mind to ask these questions in Forum next time.

I tried with selenium grid 4.3.0 and used options. But, even that did not work. The keyword got stuck and there was no logs in selenium too. Can you please let me know if below way is correct?

> call method    ${options}       to_capabilities
< {'browserName': 'safari', 'platformName': 'ios', 'ensureCleanSession': True, 'pageLoadStrategy': 'normal'}
> Open Browser    url=https://www.google.com   browser=safari   options=${options}   remote_url=http://localhost:4444

I am not sure if safari browser supports selenium options or not.

mshariqa avatar Jun 29 '22 14:06 mshariqa

I am not sure if safari browser supports selenium options or not.

That is a a good point. I am not sure. You might check that out see. In terms of options there is another format with them being "inline" with the Open Browser keyword.

[Need to go offline for a bit but will check back in a little later]

emanlove avatar Jun 29 '22 14:06 emanlove

In terms of safari's complience with W3C standards I can't, so far, find a definitive answer on that. I see this SauceLabs document which talks to the compliance to W3C standards and it seems to indicate that newer versions are compatible. It references the W3C spec for capabilities and I see three of the four you have there above in the spec. There are also within the Python port of selenium. There is some references [1] to ensureCleanSession but from what I see this is an ie only option. Noting the safari.options reference above I re-looked at the Selenium Python API doc and see that option is not under safari's options and only under ie options.

I would try removing the 'ensureCleanSession': True and see what the response is. Hopefully that works although that then would raise the question of why in python you don't get the error with that options set but you do through SeleniumLibrary. With your last code above I would expect these to be the same.

emanlove avatar Jul 01 '22 00:07 emanlove

@emanlove, I looked onto the Robot Framework SeleniumLibrary source code. I found out a log that safari browser doesnt support selenium options. https://github.com/robotframework/SeleniumLibrary/blob/7769ed6fe6565007c4938664ce7f84cce343c4cd/src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py#L352

So, even though selenium grid supports options or not Robot Framework SeleniumLibrary doesn't support safari options.

Please correct me if I am wrong.

Also, I found 'ensureCleanSession' in some legacy desired_capabilites document so I added it in options. https://www.selenium.dev/documentation/legacy/desired_capabilities/

mshariqa avatar Jul 01 '22 04:07 mshariqa