Session not created Selenium/webdriver when using Safari 12

前端 未结 2 869
北荒
北荒 2021-01-24 10:44

Since upgrading to Safari 12, my automated scripts are now getting this error:

SessionNotCreatedError: Request body does not contain required parameter \'capabil         


        
相关标签:
2条回答
  • 2021-01-24 11:28

    This issue happens because Safari 12 uses a new W3C webdriver protocol (source) which appears to be incompatible with the latest stable selenium-webdriver package (v3.6)

    safaridriver can be passed a --legacy flag to use the old protocol. Directly on the command line this would be done like: /usr/bin/safaridriver --legacy

    This flag can be set on the driver in your node program as follows:

    const webdriver = require('selenium-webdriver');
    const safari = require('selenium-webdriver/safari');
    
    new webdriver.Builder()
        .usingServer(await new safari.ServiceBuilder().addArguments('--legacy').build().start())
        .forBrowser('safari')
        .build();

    Here's documentation on the ServiceBuilder API - https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/safari_exports_ServiceBuilder.html

    A couple GitHub tickets cover this as well:

    • https://github.com/SeleniumHQ/selenium/issues/6431
    • https://github.com/SeleniumHQ/selenium/issues/6026
    0 讨论(0)
  • 2021-01-24 11:48

    This will also work if you get an error for 'await' when trying @mjdease solution above.

    new webdriver.Builder()
        .usingServer(new safari.ServiceBuilder().addArguments('--legacy').build().start())
        .forBrowser('safari')
        .build(); 
    
    0 讨论(0)
提交回复
热议问题