Skip to content

How to configure cuprite to test on mobile emulation ? #216

@jean-francois-labbe

Description

@jean-francois-labbe

I'm trying to migrate to cuprite.
I can't find any setup for mobile testing.
I have the following selenium configuration.

  options = Selenium::WebDriver::Chrome::Options.new
  options.add_argument('--no-sandbox')
  options.add_argument('--headless') unless ENV['VIEW']
  options.add_argument('--disable-dev-shm-usage')
  options.add_argument('--disable-gpu')
  options.add_argument('--window-size=1024,1024')
  options.add_option(
    :mobileEmulation,
    {
      'deviceMetrics' => { 'width' => 360, 'height' => 640, 'pixelRatio' => 3.0 },
      'userAgent' => 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) '\
      'AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19',
    },
  )
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.open_timeout = 30 # seconds
  client.read_timeout = 10 # seconds

  Capybara::Selenium::Driver.new(app, browser: :chrome, capabilities: options,
                                 http_client: client, **selenium_context.url_config)

I'd like to reproduce it with cuprite. I looked in the main repositories using cuprite (using this page). None is testing executing system tests on mobile.

Here is my current attempt.
I tried to specify the mobileEmulation option in different places.
The browsers is not using the mobile emulation.

Capybara.register_driver(:cuprite) do |app|
  Capybara::Cuprite::Driver.new(
    app,
    window_size: [360, 640],
    screen_size: [360, 640],
    browser_options: { 'no-sandbox': nil,
      'mobileEmulation': {
        'deviceMetrics' => { 'width' => 360, 'height' => 640, 'pixelRatio' => 3.0 },
        'userAgent' => 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) '\
        'AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19',
      },
    },
    headless: false,
    mobile_emulation: {
      'deviceMetrics' => { 'width' => 360, 'height' => 640, 'pixelRatio' => 3.0 },
      'userAgent' => 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) '\
      'AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19',
    },
  )
end

What am I missing ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions