Skip to content

Commit adb15af

Browse files
committed
Added usage examples to the readme
1 parent 909f4d9 commit adb15af

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

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)