Session not created Selenium/webdriver when using Safari 12

前端 未结 2 871
北荒
北荒 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

提交回复
热议问题