webdriverio / query-selector-shadow-dom

querySelector that can pierce Shadow DOM roots without knowing the path through nested shadow roots. Useful for automated testing of Web Components. Production use is not advised, this is for test environments/tools such as Web Driver, Playwright, Puppeteer
MIT License
242 stars 25 forks source link

Features/protractor locator #34

Closed jan-molak closed 4 years ago

jan-molak commented 4 years ago

Hi again, @Georgegriff !

I've prepared a simple Angular Protractor plugin that addresses #33 and should integrate nicely with Serenity/JS I'm the author of, and which uses Protractor under the hood.

So starting from the outside, a person using Angular Protractor would need to configure their test runner in their protractor.conf.js to use the query-selector-shadow-dom/plugins/protractor Protractor plugin:

    plugins: [{
        package: 'query-selector-shadow-dom/plugins/protractor'
    }],

You'll see this demonstrated in the end-to-end test I've added (see test/protractor-locator.e2e.js and protractor.conf.js)

The plugin (at plugins/protractor/index.js) follows a very similar pattern you've already established for Playwright.

Since both Serenity/JS and Protractor are written in TypeScript I've also added a plugins/protractor/index.d.ts file that describes the new method that the plugin registers on Protractor's by object.

There's a couple of things I wasn't sure of, so would appreciate your feedback on.

If you find this PR too large or out of scope for this project please let me know and I can release it as a separate lib with a dependency on yours, I don't mind.

Looking forward to hearing your thoughts!

Jan

codecov[bot] commented 4 years ago

Codecov Report

Merging #34 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #34   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           61        61           
=========================================
  Hits            61        61           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6038fb0...adb15af. Read the comment docs.

jan-molak commented 4 years ago

Hey @Georgegriff! Thanks for your feedback, I'm glad you're happy with this PR :-) I've added an example to the readme and am planning to write a short tutorial to demonstrate how to use Serenity/JS with query-selector-shadow-dom as soon as the new version of this lib lands in NPM.

I'd be happy to submit another PR linking to the article from the readme if you'd like?

Georgegriff commented 4 years ago

Yeah any more documentation more than welcome