Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing screen resolution on Sauce Labs #237

Open
taraneier opened this issue May 14, 2016 · 11 comments
Open

Changing screen resolution on Sauce Labs #237

taraneier opened this issue May 14, 2016 · 11 comments

Comments

@taraneier
Copy link

taraneier commented May 14, 2016

Greetings,

I am using the following .yml file to run my tests against Sauce Labs. Most of my tests break due to responsive design and the default resolution. I need to start up the VM with screen resolution of 1920x1200, otherwise it's getting the default value 1024x768. Unfortunately the yml isn't working and Sauce Labs is saying the problem is with the Mink Driver. Apologies if this is posted in the wrong spot.

Best regards,

Tara

sauce.yml

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Behat\MinkExtension:
      base_url: http://test-site.gotpantheon.com/
      javascript_session: sauce_labs
      selenium2:
        wd_host: un:[email protected]/wd/hub
        browser: chrome
        capabilities: { "platform": "Windows 7" , "version": "45" , "name":"Behat on Sauce" }
      sauce_labs:
        browser: chrome
        capabilities: { "screen-resolution": “1920×1200” }
@aik099 aik099 changed the title Selenium2 Driver and changing screen resolution on Sauce Changing screen resolution on Sauce Labs May 14, 2016
@aik099
Copy link
Member

aik099 commented May 14, 2016

Not sure if it matters, but you're using 2 different quoting symbols in your example:

  • " - correct one
  • and - incorrect ones that look like copy/pasted from MS Word

I guess Yaml parser might get confused and not passing screen resolution at all.

@taraneier
Copy link
Author

I fixed the quotes, but it still didn't work on Sauce Labs. I don't have MS Word, but I did grab that code from a web page.

@aik099
Copy link
Member

aik099 commented May 14, 2016

What I can suggest is compare the WebDriver logs on Sauce Labs website, when:

  • you're using Sauce Labs via Behat
  • you're starting manual session on Sauce Labs website

@taraneier
Copy link
Author

taraneier commented May 15, 2016

I did a diff -y on the selenium-server.log files for my behat session and my manual session. Here are the results up through the screen resolution steps:

diff -y behat-selenium-server.log manual-selenium-server.log 
[0.597][INFO]: COMMAND InitSession {                  | [0.567][INFO]: COMMAND InitSession {
   "desiredCapabilities": {                        "desiredCapabilities": {
                                  >       "_cyborg_id": "9453e875f6884461abe5f03f79cdb92b",
      "browserName": "chrome",                        "browserName": "chrome",
      "chromeOptions": {                          "chromeOptions": {
         "args": [ "start-maximized", "disable-webgl", "black            "args": [ "start-maximized", "disable-webgl", "black
         "binary": "D:\\Program Files\\Chrome 45\\45.0.2454.9            "binary": "D:\\Program Files\\Chrome 45\\45.0.2454.9
      },                                  },
      "debuggerAddress": "127.0.0.1:9222",                    "debuggerAddress": "127.0.0.1:9222",
      "ignoreZoomSetting": false,                     <
      "webdriver.remote.quietExceptions": true                "webdriver.remote.quietExceptions": true
   }                                   }
}                                   }
[0.598][INFO]: Populating Preferences file: {             | [0.568][INFO]: Populating Preferences file: {
   "alternate_error_pages": {                      "alternate_error_pages": {
      "enabled": false                            "enabled": false
   },                                  },
   "autofill": {                           "autofill": {
      "enabled": false                            "enabled": false
   },                                  },
   "browser": {                            "browser": {
      "check_default_browser": false                      "check_default_browser": false
   },                                  },
   "distribution": {                           "distribution": {
      "import_bookmarks": false,                      "import_bookmarks": false,
      "import_history": false,                        "import_history": false,
      "import_search_engine": false,                      "import_search_engine": false,
      "make_chrome_default_for_user": false,                  "make_chrome_default_for_user": false,
      "show_welcome_page": false,                         "show_welcome_page": false,
      "skip_first_run_ui": true                       "skip_first_run_ui": true
   },                                  },
   "dns_prefetching": {                        "dns_prefetching": {
      "enabled": false                            "enabled": false
   },                                  },
   "profile": {                            "profile": {
      "content_settings": {                           "content_settings": {
         "pattern_pairs": {                              "pattern_pairs": {
            "https://*,*": {                                "https://*,*": {
               "media-stream": {                               "media-stream": {
                  "audio": "Default",                                 "audio": "Default",
                  "video": "Default"                                  "video": "Default"
               }                                       }
            }                                       }
         }                                       }
      },                                  },
      "default_content_settings": {                       "default_content_settings": {
         "geolocation": 1,                               "geolocation": 1,
         "mouselock": 1,                             "mouselock": 1,
         "notifications": 1,                             "notifications": 1,
         "popups": 1,                                "popups": 1,
         "ppapi-broker": 1                               "ppapi-broker": 1
      },                                  },
      "password_manager_enabled": false                   "password_manager_enabled": false
   },                                  },
   "safebrowsing": {                           "safebrowsing": {
      "enabled": false                            "enabled": false
   },                                  },
   "search": {                             "search": {
      "suggest_enabled": false                        "suggest_enabled": false
   },                                  },
   "translate": {                              "translate": {
      "enabled": false                            "enabled": false
   }                                   }
}                                   }
[0.598][INFO]: Populating Local State file: {             | [0.568][INFO]: Populating Local State file: {
   "background_mode": {                        "background_mode": {
      "enabled": false                            "enabled": false
   },                                  },
   "ssl": {                                "ssl": {
      "rev_checking": {                           "rev_checking": {
         "enabled": false                                "enabled": false
      }                                   }
   }                                   }
}                                   }
[0.600][INFO]: Launching chrome: "D:\Program Files\Chrom      | [0.571][INFO]: Launching chrome: "D:\Program Files\Chrome 45\
[1.563][INFO]: RESPONSE InitSession {                 | [1.660][INFO]: RESPONSE InitSession {
   "acceptSslCerts": true,                         "acceptSslCerts": true,
   "applicationCacheEnabled": false,                   "applicationCacheEnabled": false,
   "browserConnectionEnabled": false,                  "browserConnectionEnabled": false,
   "browserName": "chrome",                        "browserName": "chrome",
   "chrome": {                             "chrome": {
      "userDataDir": "C:\\Users\\ADMINI~1\\AppData\\Loca      |       "userDataDir": "C:\\Users\\ADMINI~1\\AppData\\Local\\Te
   },                                  },
   "cssSelectorsEnabled": true,                    "cssSelectorsEnabled": true,
   "databaseEnabled": false,                       "databaseEnabled": false,
   "handlesAlerts": true,                          "handlesAlerts": true,
   "javascriptEnabled": true,                      "javascriptEnabled": true,
   "locationContextEnabled": true,                     "locationContextEnabled": true,
   "mobileEmulationEnabled": false,                    "mobileEmulationEnabled": false,
   "nativeEvents": true,                       "nativeEvents": true,
   "platform": "Windows NT",                       "platform": "Windows NT",
   "rotatable": false,                         "rotatable": false,
   "takesHeapSnapshot": true,                      "takesHeapSnapshot": true,
   "takesScreenshot": true,                        "takesScreenshot": true,
   "version": "45.0.2454.93",                      "version": "45.0.2454.93",
   "webStorageEnabled": true                       "webStorageEnabled": true
}                                   }
[1.700][INFO]: COMMAND ExecuteScript {                | [1.786][INFO]: COMMAND ExecuteScript {
   "args": [  ],                           "args": [  ],
   "script": "return screen.width"                     "script": "return screen.width"
}                                   }
[1.700][INFO]: Waiting for pending navigations...             | [1.786][INFO]: Waiting for pending navigations...
[1.700][INFO]: Done waiting for pending navigations           | [1.786][INFO]: Done waiting for pending navigations
[1.703][INFO]: Waiting for pending navigations...             | [1.790][INFO]: Waiting for pending navigations...
[1.703][INFO]: Done waiting for pending navigations           | [1.790][INFO]: Done waiting for pending navigations
[1.703][INFO]: RESPONSE ExecuteScript 1024                | [1.790][INFO]: RESPONSE ExecuteScript 1920
[1.705][INFO]: COMMAND ExecuteScript {                | [1.792][INFO]: COMMAND ExecuteScript {
   "args": [  ],                           "args": [  ],
   "script": "return screen.height"                    "script": "return screen.height"
}                                   }
[1.705][INFO]: Waiting for pending navigations...             | [1.792][INFO]: Waiting for pending navigations...
[1.705][INFO]: Done waiting for pending navigations           | [1.792][INFO]: Done waiting for pending navigations
[1.707][INFO]: Waiting for pending navigations...             | [1.794][INFO]: Waiting for pending navigations...
[1.707][INFO]: Done waiting for pending navigations           | [1.794][INFO]: Done waiting for pending navigations
[1.707][INFO]: RESPONSE ExecuteScript 768                 | [1.794][INFO]: RESPONSE ExecuteScript 1200
[1.709][INFO]: COMMAND SetWindowPosition {                | [1.796][INFO]: COMMAND SetWindowPosition {
   "windowHandle": "current",                      "windowHandle": "current",
   "x": 0,                                 "x": 0,
   "y": 0                                  "y": 0
}                                   }
[1.712][INFO]: Waiting for pending navigations...             | [1.800][INFO]: Waiting for pending navigations...
[1.727][INFO]: Done waiting for pending navigations           | [1.816][INFO]: Done waiting for pending navigations
[1.918][INFO]: RESPONSE SetWindowPosition                 | [1.969][INFO]: RESPONSE SetWindowPosition
[1.921][INFO]: COMMAND SetWindowSize {                | [1.972][INFO]: COMMAND SetWindowSize {
   "height": 768,                             |    "height": 1200,
   "width": 1024,                             |    "width": 1920,
   "windowHandle": "current"                       "windowHandle": "current"
}                                   }
[2.038][INFO]: RESPONSE SetWindowSize                 | [2.089][INFO]: RESPONSE SetWindowSize
[2.041][INFO]: COMMAND MaximizeWindow {               | [2.092][INFO]: COMMAND MaximizeWindow {
   "windowHandle": "current"                       "windowHandle": "current"
}                                   }
[2.060][INFO]: RESPONSE MaximizeWindow                | [2.207][INFO]: RESPONSE MaximizeWindow
[2.068][INFO]: COMMAND GetWindows {                   | [2.212][INFO]: COMMAND GetWindows {

}                                   }
[2.069][INFO]: RESPONSE GetWindows [ "CDwindow-2FF9F7B9-      | [2.213][INFO]: RESPONSE GetWindows [ "CDwindow-00FB9D8B-5160-
[2.130][INFO]: COMMAND SetWindowSize {                | [2.272][INFO]: COMMAND Navigate {
   "height": 900,                             <
   "width": 1440,                             <
   "windowHandle": "current"                      <
}                                     <
[2.244][INFO]: RESPONSE SetWindowSize                 <
[2.333][INFO]: COMMAND Navigate {                     <
   "url": "http://test-site.gotpantheon.com/"         <

@aik099
Copy link
Member

aik099 commented May 15, 2016

I can't read this. Maybe instead you can create gist with contents of both logs and I do a compare in my favorite app.

@taraneier
Copy link
Author

taraneier commented May 15, 2016

Derp. My apologies. Thanks for your patience. Here are the gists. I truncated the behat log at navigation. If you need more than that let me know. What is your favorite diff app, btw?

https://gist.github.com/taraneier/3418a72249ceb35a7a995f1b4b7ce041
https://gist.github.com/taraneier/debb8c546e5f2311eba692a869c88a36

@aik099
Copy link
Member

aik099 commented May 15, 2016

Here are importants parts from above logs.

When Behat does that:

COMMAND SetWindowSize {
   "height": 768,
   "width": 1024,
   "windowHandle": "current"
}

COMMAND SetWindowSize {
   "height": 900,
   "width": 1440,
   "windowHandle": "current"
}

When user is doing that:

SetWindowSize {
   "height": 1200,
   "width": 1920,
   "windowHandle": "current"
}

Interesting is that according to .behat.yml the 2nd command for changing screen resolution must be using 1920x1200 and not 1440x900.

Still have no idea why this is happening like that.

@taraneier
Copy link
Author

taraneier commented May 16, 2016

I have updated the behat-selenium-server.log. The 1440x900 came from an attempt I made with changing the screen resolution with FeatureContext.php as shown below. I have removed that part of the FeatureContext.php and re-ran the tests and updated the log.
updated log:
https://gist.github.com/taraneier/debb8c546e5f2311eba692a869c88a36

FeatureContext.php - before removing @BeforeScenario section
https://gist.github.com/taraneier/617b98a1ad8fe85dfedadc2d1384c35f

@crossan007
Copy link

Is there a solution for this? I'm trying to accomplish something similar...

@aik099
Copy link
Member

aik099 commented Jul 28, 2017

I have no idea. Maybe Sauce Labs support needs to be contacted for any solution that we later can implement in the driver.

@robocoder
Copy link
Contributor

It looks like SauceLabs renamed many of the capabilities for consistency. A couple were camelCase (e.g., deviceOrientation and deviceType) while others used hyphens (e.g., screen-resolution). They're now all camelCase.

In this case,screen-resolution is now screenResolution.

You'll want to open an issue/PR against Behat/MinkExtension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants