Codeception: Unable to emulate mobile chrome.

Created on 21 Dec 2016  路  8Comments  路  Source: Codeception/Codeception

What are you trying to achieve?

Run tests in chrome mobile emulation: Reproduce invalid UI output, occurring when accessing from mobile.

What do you get instead?

UI output is valid. No emulation happened. Of course manually emulating the device, the output is invalid.

Details

  • Codeception version: 2.2
  • PHP Version: 5.5.9
  • Operating System: Ubuntu 14.04
  • Installation type: Composer
  • Selenium: 3.0.1
  • Chrome driver: 2.26
  • Suite configuration:
env:
    top:
         modules:
            config:
                WebDriver:
                    browser: 'chrome'
                    window_size: 360x640 # Logically this should not be needed
                    capabilities:
                      platform: ANDROID
                      browserName: chrome
                      mobileEmulation:
                        deviceName: 'Galaxy S5'

Codeception browser capabilities
Capabilities & ChromeOptions Search: mobileEmulation

Most helpful comment

I was right, my configuration was incorrect.

So if you need to start codeception tests in mobile emulation mode here's the environment section you need to use:

env:
    top:
         modules:
            config:
                WebDriver:
                    browser: 'chrome'
                    window_size: 360x640
                    capabilities:
                       platform: ANDROID
                       browserName: chrome
                       chromeOptions:
                            mobileEmulation:
                                 deviceName: 'Samsung Galaxy S4'

Just putting the mobile resolution is not enough. We need to put the tests in mobile emulation.

E.g. when using chosen jquery plugin. Simply resizing to a mobile size, said library seemed to be working correctly. However, when testing from an actual mobile device it was not. The above configuration achieves this.

All 8 comments

It isn't an issue of Codeception.

@Naktibalda OK thanks.

Wasn't sure the below configuration was correct.

                      mobileEmulation:
                        deviceName: 'Galaxy S5'

I was right, my configuration was incorrect.

So if you need to start codeception tests in mobile emulation mode here's the environment section you need to use:

env:
    top:
         modules:
            config:
                WebDriver:
                    browser: 'chrome'
                    window_size: 360x640
                    capabilities:
                       platform: ANDROID
                       browserName: chrome
                       chromeOptions:
                            mobileEmulation:
                                 deviceName: 'Samsung Galaxy S4'

Just putting the mobile resolution is not enough. We need to put the tests in mobile emulation.

E.g. when using chosen jquery plugin. Simply resizing to a mobile size, said library seemed to be working correctly. However, when testing from an actual mobile device it was not. The above configuration achieves this.

I had problems with this code, especially with "deviceName".
Actual list of "deviceName" you can find here.

Thanks for the update @vabue you probably saved me some time from my next upcoming acceptance tests run-through :) It seems the Samsung Galaxy S4 is not supported anymore from the Chrome driver. Logical as the above comment was six month ago.

@vabue would you mind listing the Chrome driver and Selenium version you're using?

@rdok sure.
Selenium Server 3.4.0
Google Chrome Driver 2.29
MS Windows 10, 64bit.

Also, I'm wondering is there a possibility to use mobile emulation in other browsers: Firefox, Safari, Edge.

Was this page helpful?
0 / 5 - 0 ratings