Reading Time: 1 minute
This post is part of a ten-part series on how to write better Protractor tests. You can find the rest of the series here
One of the most painful parts of Protractor can be figuring out the right selector for locating an element. New versions of Protractor support the
--elementExplorer option, which give us a REPL where we can control a running browser, interactively from the command line!
npm install protractor
./node_modules/protractor/bin/webdriver-manager update --chrome
It should drop you in to a repl where you can try this:
Generally what I’ll do is after I’ve booted the
elementExplorer browser instance, I’ll log in by hand (in Chrome, manually) to navigate to the page I’m interested in. Then I’ll look for
elements from there.
The good: This is a super-fast way for you to try out Protractor expressions without having to write the test and then run through it
The bad: You can’t use your custom Page Objects in this REPL and if you have a syntax error it sometimes crashes which means you have to start over.
Learn Protractor in a few hours with our online course
Protractor is a one of the best ways to ensure your app is working correctly because you can write code that acts like a real user. But Protractor can also be confusing and difficult to work with when you're just starting out. We've put together an online course that will help you become a master at Protractor.
You'll save tons of time and frustration learning Protractor because we've worked out everything you need to know. Become a Protractor testing master today!