How to configure the browser driver as a mobile device [Mobile Emulation]

Hi team, I am testing a web product and want to configure the browser driver as a mobile device, similar to the screenshot, I haven’t found the right setting in the document (https://docs.katalon.com), maybe I haven’t found it, could someone please help me :rofl:

I found the same question in forum before~

@michael.hollander

Launching Chrome with device emulation enabled

@Aliasger_Kiranawala

How to set user-agent of a browser for execution as Mobile web?

@Gordon Its possible to set the size resolution but user agent we can set as chrome browser capability. Issue is I was not able to verify if the user agent is set or not, although browser was opening with set resolution.

Hi @Gordon,

In Chrome, it’s called Mobile Emulation

How it works in Katalon:

  • Step 1: Open `Project Setting/Desired Capabilities/Web UI/Chrome’
  • Step 2: Add this property on the table of properties:
mobileEmulation: {deviceName=Nexus 5}

Note that the Nexus 5 is an example.

5 Likes

thanks a lot, it works well~
when the browser driver is started, it will get the resolution of the device which having set

1 Like

This is very helpful. Thank you very much!

One last question, though: Is it possible to pragmatically set the mobileEmulation value during a test case? If possible, I’d like to test a few models of phones by setting the value and looping the test case, rather than have a separate project for each model I intend to test.

Hi @duyluong,

Can you please explain more how to add that values.

i have followed your steps but didn’t work for me

Someone tried to add the orientation to LANDSCAPE?
I tried but did not work or I made something wrong.

I resolve that problem.
Value:
Driver Name: Chrome

Preferences:
Name: mobileEmulation
Type: Dictionary

Value:
Name: deviceName
Type: String
Value: Nexus 6

Name: orientation
Type: String
Value: LANDSCAPE

Name: platformName
Type: String
Value: Android

Name: platformVersion
Type: String
Value: 9.0

1 Like

Hi, Can you share the Step by Step procedure. I’m just new in mobile testing.

Where to put this and is this needed?

Map<String, String> mobileEmulation = new HashMap<>();

mobileEmulation.put(“deviceName”, “Nexus 5”);

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption(“mobileEmulation”, mobileEmulation);

WebDriver driver = new ChromeDriver(chromeOptions);

or this is enough following the steps below?

How it works in Katalon:
•Step 1: Open `Project Setting/Desired Capabilities/Web UI/Chrome’
•Step 2: Add this property on the table of properties:
mobileEmulation: {deviceName=Nexus 5}

1 Like

HI,
I have same problem.
I try this:

**1st. **
•Step 1: Open `Project Setting/Desired Capabilities/Web UI/Chrome’
•Step 2: Add this property on the table of properties:
mobileEmulation: {deviceName=Galaxy S5}

2.nd
use code
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put(“deviceName”, “Galaxy S5”);

2 Likes

Thanks, I have successfully run it.

Hi, Can you share the Step,
Where to put this code ? for each case?
2.nd
use code
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put(“deviceName”, “Galaxy S5”);