Skip to content

Commit

Permalink
Use WebdriverIOs driver setup mechanism (#105)
Browse files Browse the repository at this point in the history
* Remove npm packages for `chromedriver`:

* `wdio-chromedriver-service`
* `chromedriver`
* `@types/chromedriver`

* Use WebdriverIO's driver setup mechanism

* Cache "chromium" version

* Use the same encoding as below

* Trim version

* Remove browserName

* Code review changes

* Update the minimum supported version in CI

* Update the minimum supported version in CI

* Document the required version of webdriverio and how to configure Chromedriver
  • Loading branch information
seanpoulter authored Feb 15, 2024
1 parent 4665af8 commit b661258
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 414 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
vscodeVersion:
# - insiders
- stable
- 1.83.0
- 1.86.0
- web
runs-on: ${{ matrix.os }}

Expand Down
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ This WebdriverIO service allows you to seamlessly test your VSCode extensions fr

This project was highly inspired by the [vscode-extension-tester](https://www.npmjs.com/package/vscode-extension-tester) project which is based on Selenium. This package takes the idea and adapts it to WebdriverIO.

Starting from VSCode v1.86 it is required to use `webdriverio` v8.14 or later to install Chromedriver with no configuration necessary. If you need to test earlier versions of VSCode, see the [Chromedriver configuration](#chromedriver) section below.

## Installation

To initiate a new WebdriverIO project, run:
Expand All @@ -35,8 +37,6 @@ An installation wizard will guide you through the process. Ensure you select Typ

![Install Demo](https://raw.githubusercontent.com/webdriverio-community/wdio-vscode-service/main/.github/assets/demo.gif "Install Demo")

__Note:__ remove `chromedriver` from the list of services in the generated `wdio.conf.ts` afterward. See also the configuration example below.

For more information on how to install `WebdriverIO`, please check the [project docs](https://webdriver.io/docs/gettingstarted).

## Example Configuration
Expand All @@ -50,7 +50,7 @@ export const config = {
// ...
capabilities: [{
browserName: 'vscode',
browserVersion: '1.71.0', // "insiders" or "stable" for latest VSCode version
browserVersion: '1.86.0', // "insiders" or "stable" for latest VSCode version
'wdio:vscodeOptions': {
extensionPath: __dirname,
userSettings: {
Expand All @@ -60,8 +60,7 @@ export const config = {
}],
services: ['vscode'],
/**
* optionally you can define the path WebdriverIO stores all
* VSCode and Chromedriver binaries, e.g.:
* Optionally define the path WebdriverIO stores all VSCode binaries, e.g.:
* services: [['vscode', { cachePath: __dirname }]]
*/
// ...
Expand Down Expand Up @@ -145,11 +144,11 @@ Through service configuration, you can manage the VSCode version as well as user

### Service Options

Service options are options needed for the service to set up the test environment. They are a superset of the [Chromedriver options](https://webdriver.io/docs/wdio-chromedriver-service#options) which can be applied for this service as well.
Service options are options needed for the service to set up the test environment.

#### `cachePath`

Define a cache path to avoid re-downloading VS Code bundles. This is useful for CI/CD to avoid re-downloading VSCode and Chromedriver for every test run.
Define a cache path to avoid re-downloading VS Code bundles. This is useful for CI/CD to avoid re-downloading VSCode for every test run.

Type: `string`<br />
Default: `process.cwd()`
Expand Down Expand Up @@ -253,6 +252,24 @@ Default:
}
```

### Chromedriver

Starting from VSCode v1.86 it is required to use `webdriverio` v8.14 or later to install Chromedriver with no configuration necessary. The [simplified browser automation setup](https://webdriver.io/blog/2023/07/31/driver-management) handles everything for you.

To test earlier versions of VS Code, find the expected version of Chromedriver from the logs, download [Chromedriver](https://chromedriver.chromium.org/downloads), and configure the path. For example:

```
[0-0] ERROR webdriver: Failed downloading chromedriver v108: Download failed: ...
```

```ts
capabilities: [{
browserName: 'vscode',
browserVersion: '1.80.0',
'wdio:chromedriverOptions': {
binary: path.join(cacheDir, 'chromedriver-108.0.5359.71')
```
## Create Your Own PageObjects
You can reuse the components used in this service for your own review page objects. For that first create a file that defines all your selectors, e.g.:
Expand Down
Loading

0 comments on commit b661258

Please sign in to comment.