send command to browser

Description

Send JSON string request to Google Chrome’s Device Mode in order to invoke a new mobile browser emulator, or change environment for a given mobile browser emulator to customize its behaviors during the test run.

Arguments

Valid contexts

This action may be used within the following project items: test modules and user-defined actions.

Applicable Systems/Platforms

Use of this action is supported on the following systems/platforms:Chrome DevTools’s Device Mode on Windows.

Applicable Built-In Settings

The following setting is applicable to this action: window wait.

Notes

Example

Assume that you have set up a Chrome Device Mode mobile device emulator by means of writing a defined JSON profile to the action send command to browser.

During the test run, you’d like to customize certain aspects of the emulator’s environment. You accomplish this with the send command to browser action, sending the appropriate JSON strings through its command argument. The features to be changed (and their corresponding JSON command strings) are:

Action Lines

//Launch Google Chrome   
                            setting                    value
setting                     use browser                Chrome

//Navigate to a URL in Chrome

                            location
navigate                    https://www.google.com/

//Invoke a specified emulator in Chrome's Device Mode

                            window                    command                                                                                                                                                                                                           variable             
send command to browser     google                    [{"method":"Network.setUserAgentOverride","params":{"userAgent":"Mozilla/5.0 (Linux; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.114 Mobile Safari/537.36"}},    >>emulator
                                                      {"method":"Emulation.setDeviceMetricsOverride","params":{"mobile":true,"width":260,"height":640,"deviceScaleFactor":2,"fitWindow":false}},
                                                      {"method":"Emulation.setTouchEmulationEnabled","params":{"enabled":true}}]

//Refresh the page to ensure the emulator takes effect

                            window
refresh                     google

//Develop web automation here

//Change environment to customize emulator behaviors on-the-fly
                            
                            window                    command                                                                                                                                                                                                          variable
send command to browser     google                    [{"method":"Network.setUserAgentOverride","params":{"userAgent":"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36"}},     >>new_behavior
                                                      {"method":"Network.emulateNetworkConditions","params":{  `"offline":false,"latency":100,"downloadThroughput":750,"uploadThroughput":250`}},
                                                      {"method":"Emulation.setGeolocationOverride","params":{  `"latitude":16,"longitude":108,"accuracy":1`}},
                                                      {"method":"DeviceOrientation.setDeviceOrientationOverride","params":{  `"alpha":32,"beta":26,"gamma":7`}}]

//Refresh the page to ensure all new behaviors take effect

                            window
refresh                     google

Copyright © 2024 LogiGear Corporation. All rights reserved. LogiGearはLogiGear Corporationの登録商標であり、Action Based TestingおよびTestArchitectはLogiGear Corporationの商標です。ここに記載されているその他の商標は、各所有者の財産です。

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1 (650) 572-1400