Skip to content

Commit 1bbcdcd

Browse files
authored
Merge pull request #34 from jan-molak/features/protractor-locator
Features/protractor locator
2 parents 6038fb0 + adb15af commit 1bbcdcd

File tree

9 files changed

+1201
-22
lines changed

9 files changed

+1201
-22
lines changed

.gitignore

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
# IDEs
2+
.vscode
3+
.idea
4+
5+
# Build artifacts
16
node_modules
27
dist
3-
.vscode
48
coverage
59
.DS_Store
6-
**/output/**
10+
**/output/**

.travis.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
language: node_js
2+
dist: xenial
3+
os: linux
24
node_js:
3-
- "8"
4-
before_script:
5-
- export DISPLAY=:99.0
6-
- sh -e /etc/init.d/xvfb start
7-
dist: trusty
5+
- "10"
6+
services:
7+
- xvfb
88
sudo: required
99
addons:
1010
chrome: stable
@@ -17,6 +17,7 @@ install:
1717
script:
1818
- mkdir -p dist
1919
- npm run test:ci
20+
- npm run e2e:protractor
2021
after_success:
2122
- npm install -g codecov
2223
- codecov

README.md

+37-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { querySelectorAllDeep, querySelectorDeep } from 'query-selector-shadow-d
1616

1717
Both of the methods above accept a 2nd parameter, see section `Provide alternative node`. This will change the starting element to search from i.e. it will find ancestors of that node that match the query.
1818

19-
## Examples
19+
## Integrations
2020

2121
### CodeceptJS
2222

@@ -49,6 +49,42 @@ const playwright = require('playwright');
4949

5050
For a full example see: https://github.com/Georgegriff/query-selector-shadow-dom/blob/master/examples/playwright
5151

52+
53+
### Protractor
54+
55+
This project provides a Protractor plugin, which can be enabled in your [`protractor.conf.js`](https://www.protractortest.org/#/api-overview) file:
56+
57+
```javascript
58+
exports.config = {
59+
plugins: [{
60+
package: 'query-selector-shadow-dom/plugins/protractor'
61+
}],
62+
63+
// ... other Protractor-specific config
64+
};
65+
```
66+
67+
The plugin registers a new [locator](https://www.protractortest.org/#/api?view=ProtractorBy) - `by.shadowDomCss(selector /* string */)`, which can be used in regular Protractor tests:
68+
69+
```javascript
70+
element(by.shadowDomCss('#item-in-shadow-dom'))
71+
```
72+
73+
The locator also works with [Serenity/JS](https://serenity-js.org) tests that [use Protractor](https://serenity-js.org/modules/protractor) under the hood:
74+
75+
```typescript
76+
import 'query-selector-shadow-dom/plugins/protractor';
77+
import { Target } from '@serenity-js/protractor'
78+
import { by } from 'protractor';
79+
80+
const ElementOfInterest = Target.the('element of interest')
81+
.located(by.shadowDomCss('#item-in-shadow-dom'))
82+
```
83+
84+
See the [end-to-end tests](https://github.com/Georgegriff/query-selector-shadow-dom/blob/features/protractor-locator/test/protractor-locator.e2e.js) for more examples.
85+
86+
## Examples
87+
5288
### Provide alternative node
5389
```javascript
5490
// query from another node

0 commit comments

Comments
 (0)