1

我没有找到有关如何使用 Safari 技术预览正确设置 nightwatch 配置的任何信息。

我试过这样的事情:

module.exports = {
    "src_folders": [
        "suites"
    ],
    "output_folder": "reports",
    "custom_commands_path": "commands",
    "page_objects_path": "pageObjects",
    "globals_path": "globals.js",
    "selenium": {
        "start_process": true,
        "server_path": seleniumServer.path,
        "host": "127.0.0.1",
        "port": 4444,
        "log_path": "logs",
        "cli_args": {
            "webdriver.chrome.driver": chromedriver.path,
            "webdriver.firefox.driver": '/usr/bin/geckodriver',
            "webdriver.safari.driver": '/usr/bin/safaridriver'
        }
    },
    "test_settings": {
        "default": {
            "launch_url": "http://google.com",
            "screenshots": {
                "enabled": true,
                "on_failure" : true,
                "on_error" : true
            },
            "globals": {
                "waitForConditionTimeout": 5000,
                "retryAssertionTimeout": 5000
            },
            "desiredCapabilities": {
                "browserName": "safari",
                "browserVersion": "12",
                "technologyPreview": true
            },
            "skip_testcases_on_fail": false,
            "end_session_on_fail": false
        }
    }
};

但执行后我得到这个错误:

{ value: 
   { message: 'Could not create a session: A browser with name \'safari\' version \'12\' could not be found on the system.\nBuild info: version: \'3.13.0\', revision: \'2f0d292\', time: \'2018-06-25T15:32:19.891Z\'\nSystem info: host: \'Boostas-MacBook-Pro-5.local\', ip: \'fe80:0:0:0:100a:70f9:d6d7:cbfc%en0\', os.name: \'Mac OS X\', os.arch: \'x86_64\', os.version: \'10.13.6\', java.version: \'10.0.1\'\nDriver info: driver.version: unknown\nremote stacktrace: ',
     error: 'session not created' },
  status: 33 }

注意:如果我设置technologyPreview为 false,测试将在 Safari 浏览器中运行。

希望你们能帮助我!

4

1 回答 1

0

这两个选项在我的案例中nightwatch.json用于启动 Safari 技术预览:

  "desiredCapabilities": {
    "browserName": "safari",
    "safari.options": {"technologyPreview": true},
  }

有用的参考:https ://macops.ca/using-safari-technology-preview-with-selenium-webdriver/

希望这可以帮助 !

于 2018-12-11T10:59:59.670 回答