如何在Nightwatch中启动Safari浏览器的最大化窗口

问题描述

Nightwatch配置文件

"globals_path":"./nightwatch/global.js","detailed_output":true,"disable_colors":false,"output_folder":"./tests_output","webdriver":{
   "start_process":true
},"selenium":{
   "start_process":true,"port":4444,"host":"localhost","server_path":"./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.59.jar","log_path":"","version2":true,"cli_args":{
      "webdriver.gecko.driver":"./node_modules/geckodriver/bin/geckodriver","webdriver.chrome.driver":"./node_modules/chromedriver/lib/chromedriver/chromedriver","webdriver.safari.driver":"/usr/bin/safaridriver"
   }
},"test_settings":{
   "default":{
      "launch_url":"https://www.google.com","silent":true,"skip_testcases_on_fail":false,"end_session_on_fail":false,"screenshots":{
         "enabled":true,"path":"./screenshots"
      },"webdriver":{
         "start_process":true,"server_path":"/usr/bin/safaridriver","port":0,"cli_args":[
            "--verbose"
         ]
      },"desiredCapabilities":{
         "browserName":"Safari","javascriptEnabled":true,"acceptSslCerts":true,"safari.options":{
            "excludeSwitches":[
               "enable-automation"
            ],"args":[
               "start-maximized","window-size=1980,1024","--disable-web-security","--disable-notifications","--private"
            ]
         }
      }
   },

嗨, 上面的代码Nightwatch.js文件,其配置为desiredCapalibitiessafaridriver。我已经提到了start-maximized命令,并且还设置了窗口大小,我的窗口大小是(1280X800),但仍然没有在最大化窗口中打开。我已经检查了Safari浏览器的Allow Remote Automation选项,还检查了Safari的“偏好设置”部分下的Show Developer menu in menu bar,但是没有任何选项起作用。

您能建议我使用Safari浏览器的其他选项还是进行设置?

有人可以告诉我如何在新的最大化窗口中启动safaridriver吗?

解决方法

另一个选项是在全局配置文件的 browser.maximizeWindow(); 钩子中设置 beforeEach