Пример #1
0
        /// <summary>
        /// Allows the Chromium browser to emulate a mobile device.
        /// </summary>
        /// <param name="deviceSettings">The <see cref="ChromeMobileEmulationDeviceSettings"/>
        /// object containing the settings of the device to emulate.</param>
        /// <exception cref="ArgumentException">Thrown if the device settings option does
        /// not have a user agent string set.</exception>
        /// <remarks>Specifying an invalid device name will not throw an exeption, but
        /// will generate an error in Chrome when the driver starts. To unset mobile
        /// emulation, call this method with <see langword="null"/> as the argument.</remarks>
        public void EnableMobileEmulation(ChromiumMobileEmulationDeviceSettings deviceSettings)
        {
            this.mobileEmulationDeviceName = null;
            if (deviceSettings != null && string.IsNullOrEmpty(deviceSettings.UserAgent))
            {
                throw new ArgumentException("Device settings must include a user agent string.", "deviceSettings");
            }

            this.mobileEmulationDeviceSettings = deviceSettings;
        }
Пример #2
0
 /// <summary>
 /// Allows the Chromium browser to emulate a mobile device.
 /// </summary>
 /// <param name="deviceName">The name of the device to emulate. The device name must be a
 /// valid device name from the Chrome DevTools Emulation panel.</param>
 /// <remarks>Specifying an invalid device name will not throw an exeption, but
 /// will generate an error in Chrome when the driver starts. To unset mobile
 /// emulation, call this method with <see langword="null"/> as the argument.</remarks>
 public void EnableMobileEmulation(string deviceName)
 {
     this.mobileEmulationDeviceSettings = null;
     this.mobileEmulationDeviceName     = deviceName;
 }