Is it possible to get an element by its name like you can with jQuery? I'm trying to do the equivalent of the jQuery selector like in jQuery
$('h1')
how is this done with protractor?
I tried
element('h1')
but it doesn't work
To select an HTML element using its id, we use a hash(#) symbol followed by id. In the following example, the id selector selects an element with id=“head1” and adjusts its alignment to the left while color to aqua. Class selector styles an HTML element on the basis of a specific class attribute.
you can use nth-child() selector to access to a child element.
There's a couple ways to do this - you can either get it by tagName or by css selector. So any of the following work:
element(by.css('h1')); // works with any css selector
$('h1'); // works with any css selector
element(by.tagName('h1'));
The answer was finally found on github they have a test file that shows all the selectors
element(by.css('h1'));
element(by.css('.my-class'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With