Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locate a button by css and buttonText

Tags:

protractor

I have some buttons with the same text on the same page, how can i locate one of them if I want to use both element(by.buttonText("")) and element(by.css(""))?

thanks

like image 726
Ariel Avatar asked Feb 06 '26 08:02

Ariel


1 Answers

It depends on your approach and how your HTML tag looks like.
If there is a unique attribute, you can use that.
e.g. element(by.cssContainingText('[class="something unique"]', 'Button 1'))

Another way is to get the element or DIV holding the button.
e.g. element(by.id('DIV-ID')).element(by.buttonText('Button 1'))

If you can share your html tag, it would be much easier.

like image 128
PQ Co Avatar answered Feb 13 '26 05:02

PQ Co



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!