How to launch maximised window of Safari Browser in Nightwatch

657 Views Asked by At

Nightwatch Configuration file:

"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"
            ]
         }
      }
   },

Hi, The above code is the Nightwatch.js file with the configuration of desiredCapalibities and safaridriver. I have mentioned the start-maximized command and also, set the window size and my window size is (1280X800) but still, it is not opening in the maximized window. I have checked the Safari browser Allow Remote Automation option and also check the Show Developer menu in menu bar under the preferences section of Safari but no option is working.

Can you please suggest any other option or set up I need for the Safari browser?

Can anybody tell me how I can launch safaridriver in a new and maximized window?

1

There are 1 best solutions below

0
On

Another option is to set browser.maximizeWindow(); in the beforeEach hook in global configuration file