Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add info about Chrome-specific features #1513

Merged

Conversation

AlexanderMoskovkin
Copy link
Contributor

/cc @lexkazakov @DevExpress/testcafe

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 77107b7 have failed. See details.

Copy link
Contributor

@alcazaco alcazaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit dca7232 have passed. See details.

Copy link
Contributor

@AndreyBelym AndreyBelym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

* **cdpPort=\<int\>** - an open port used for the Chrome Debugging Protocol.
* **cmdArgs** - command line [arguments](../command-line-interface.html#starting-browser-with-arguments) that are passed to the chrome.

> The CDP requires an open port to work. TestCafe automatically selects an open port, but you can define a custom port.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO 'free port' is more suitable here.

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit ca37961 have passed. See details.

@@ -99,6 +100,25 @@ You can also use the [--qr-code](#--qr-code) option to display QR-codes that rep
Scan the QR-codes by using the device on which you are going to test your application.
As a result, the browsers will be connected to TestCafe and tests will start.

### Using Chrome-specific Features
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be referenced in "Local Browsers" section

testcafe "chrome:headless" tests/sample-fixture.js
```

You can specify a custom port for CDP:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why I need to do that? Can we point to the CDP docs or smthg for those who don't familiar with protocol?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not about CDP, it's about a network configuration on your machine, e.g. available ports numbers are whitelisted in your firewall.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically justifies my request: I have no idea what's it for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should write something like We use Chrome Debugging Protocol to enable this features. It's required an available port to work with it. You can set the port via ... If the custom port is not specified, then TestCafe automatically assigns a free port. And provide with some proof link

testcafe "chrome:headless:cdpPort=9223" tests/sample-fixture.js
```

Note that headless mode is available for Mac and Linux in Chrome 59. You need a [Canary build](https://www.google.com/chrome/browser/canary.html) to enable headless mode on Windows. Specify a path to installation location, if you install a portable version of Chrome:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a special decoration styles for notes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's break this into 2 parts:

The headless mode is available for Mac and Linux in Chrome 59. You need a Canary build to enable headless mode on Windows.

Specify a path to installation location, if you install a portable version of Chrome:


You can run test in Chrome's built-in [device emulator](https://developers.google.com/web/tools/chrome-devtools/device-mode/):

```sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For two separate examples we need two separate code blocks, otherwise it looks like I need to run both commands to make this functionality work.

Options:

* **pathToBrowser** - specifies a path to a portable browser. The path to browser is not required, if it is installed in a system.
* **headless** - Chrome runs in [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enables "headless mode"

* **emulation** - allows you to run tests in Chrome [device emulator](https://developers.google.com/web/tools/chrome-devtools/device-mode/).
* **chrome arguments** - options separated by `;`. The following arguments are available:
* **device parameters**:
* **device=\<string\>** - the emulated device;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where can I find the list of available device names?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can look for them in DevTools. Open DevTools -> ⠇->Settings -> Devices

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a rhetoric question

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

device=<string> - the emulated device (see the full list of supported devices in DevTools -> ⠇->Settings -> Devices);

* **mobile=\<bool\>** - whether to emulate a mobile device;
* **orientation=\<vertical|horizontal\>** - the device orientation;
* **userAgent=\<string\>** - the user agent string;
* **touch=\<bool\>** - whether the touch support is enabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"enables touch support"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enables or disables touch support

* **cdpPort=\<int\>** - a free port used for the Chrome Debugging Protocol.
* **cmdArgs** - command line [arguments](../command-line-interface.html#starting-browser-with-arguments) that are passed to the chrome.

> The CDP requires a free port to work. TestCafe automatically selects a free port, but you can define a custom port.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If the custom port is not specified, then TestCafe automatically assigns a free port."

* **chrome arguments** - options separated by `;`. The following arguments are available:
* **device parameters**:
* **device=\<string\>** - the emulated device;
* **width=\<number\>** - the device screen width in pixels;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a table (like we use in other API descriptions) with property type and defaults values, instead of this notation?

* **userAgent=\<string\>** - the user agent string;
* **touch=\<bool\>** - whether the touch support is enabled.
* **CDP arguments**:
* **cdpPort=\<int\>** - a free port used for the Chrome Debugging Protocol.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why int here? Can I specify `-13371337" as a port number?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure it's obvious what ints we do mean :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, first of all it's inconsistent: we use "Number" everywhere (there is no such thing as "int" in JS). Also, we usually specify valid range for port number

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cdpPort=<number> - a free port (0-65535) used for the Chrome Debugging Protocol.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit cc563cc have failed. See details.

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 107c5b6 have passed. See details.

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 107c5b6 have passed. See details.

@AlexanderMoskovkin
Copy link
Contributor Author

FPR
/cc @lexkazakov @DevExpress/testcafe

Copy link
Contributor

@alcazaco alcazaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs improvements

`height` *(optional)* | Number | The device screen height in pixels. | No default value. If the device height is not set specify the emulated device name the `device` property.
`scaleFactor` *(optional)* | Number | Device scale factor value. | `1`
`mobile` *(optional)* | Boolean | Whether to emulate a mobile device. | `true` if a mobile device is set via the device property. Otherwise `false`.
`device` *(optional)* | String | The emulated device name (see the full list of supported devices in DevTools -> ⠇->Settings -> Devices). | No default value. If the device name is not set specify the custom device parameters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify the custom device parameters, if the device name is not set.

`scaleFactor` *(optional)* | Number | Device scale factor value. | `1`
`mobile` *(optional)* | Boolean | Whether to emulate a mobile device. | `true` if a mobile device is set via the device property. Otherwise `false`.
`device` *(optional)* | String | The emulated device name (see the full list of supported devices in DevTools -> ⠇->Settings -> Devices). | No default value. If the device name is not set specify the custom device parameters.
`width` *(optional)* | Number | The device screen width in pixels. | No default value. If the device width is not set specify the emulated device name via the `device` property.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify the emulated device name using the device property, if the device width is not set.

`mobile` *(optional)* | Boolean | Whether to emulate a mobile device. | `true` if a mobile device is set via the device property. Otherwise `false`.
`device` *(optional)* | String | The emulated device name (see the full list of supported devices in DevTools -> ⠇->Settings -> Devices). | No default value. If the device name is not set specify the custom device parameters.
`width` *(optional)* | Number | The device screen width in pixels. | No default value. If the device width is not set specify the emulated device name via the `device` property.
`height` *(optional)* | Number | The device screen height in pixels. | No default value. If the device height is not set specify the emulated device name via the `device` property.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify the emulated device name using the device property, if the device height is not set.

`device` *(optional)* | String | The emulated device name (see the full list of supported devices in DevTools -> ⠇->Settings -> Devices). | No default value. If the device name is not set specify the custom device parameters.
`width` *(optional)* | Number | The device screen width in pixels. | No default value. If the device width is not set specify the emulated device name via the `device` property.
`height` *(optional)* | Number | The device screen height in pixels. | No default value. If the device height is not set specify the emulated device name via the `device` property.
`scaleFactor` *(optional)* | Number | Device scale factor value. | Depends on chosen `device` or your system parameters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on a chosen device or your system parameters.

`width` *(optional)* | Number | The device screen width in pixels. | No default value. If the device width is not set specify the emulated device name via the `device` property.
`height` *(optional)* | Number | The device screen height in pixels. | No default value. If the device height is not set specify the emulated device name via the `device` property.
`scaleFactor` *(optional)* | Number | Device scale factor value. | Depends on chosen `device` or your system parameters.
`mobile` *(optional)* | Boolean | Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. | `true` if a mobile device is set via the `device` property. Otherwise `false`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether to emulate a mobile device. This includes the viewport meta tag, overlay scrollbars, text autosizing and more. | true if a mobile device is set via the device property. Otherwise false.

`userAgent` *(optional)* | String | The user agent string | Default browser's user agent string
`touch` *(optional)* | Boolean | Enables or disables touch support | `true` if a touch-supported device is set via the device property. Otherwise `false`.
`userAgent` *(optional)* | String | The user agent string | The user agent string of the selected `device` or the browser.
`touch` *(optional)* | Boolean | Enables or disables touch event emulation. | `true` if a touch-supported device is set via the `device` property or your system supports touch events. Otherwise `false`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enables or disables the touch event emulation. | true if a touch-supported device is set via the device property or your system supports touch events. Otherwise false.

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 9c9aa5a have passed. See details.

@AlexanderMoskovkin
Copy link
Contributor Author

FPR

@AlexanderMoskovkin
Copy link
Contributor Author

/cc @lexkazakov @DevExpress/testcafe

Copy link
Contributor

@alcazaco alcazaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

```sh
testcafe "chrome:path/to/chrome:headless" tests/sample-fixture.js
```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the headless mode the browser's viewport size is 1280x800 by default. You can change it via the (ResizeWindow)[../../test-api/actions/resize-window.html] command or via Device Emulation Mode parameters.

/cc @lexkazakov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In headless mode the browser's viewport size is 1280x800 by default. You can change it via the (ResizeWindow)[../../test-api/actions/resize-window.html] command or via Device Emulation Mode parameters.

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit c2a089a have passed. See details.

@AlexanderMoskovkin AlexanderMoskovkin merged commit 5c81d34 into DevExpress:master Jun 13, 2017
@AlexanderMoskovkin AlexanderMoskovkin deleted the docs-chrome-features branch August 15, 2017 14:42
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request Dec 18, 2019
* [docs] Add info about Chrome-specific features

* use node v7

* open port -> free port

* Reworked

* Update cdp arguments description

* Fix tests

* Small update

* One more small update

* Remarks

* Add viewport size in headless mode info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants