angularjs - How to click the buttons without element id -
im using protractor e2e testing.i want click buttons
is there reason you're not using protractor api, driver directly? selecting ng-click might not best approach here (good practice seems selecting based on page structure, not mechanics), recommend investigate if can't use by.buttontext:
element(by.buttontext('place order'));
edit: looking @ way selector made, above not work - please note by.buttontext match:
- button
- input type="button"
- input type="submit"
i'm keeping might need in future.
if not work, maybe @ least select class, e.g. inside parent? example:
element(by.css('.btn-wrapper > .btn:nth-child(2)'));
also, consider adding separate class/id button, might useful later anyway.
last remark, if have large page test, consider using page objects instead of selecting same stuff in separate steps. way, instead of writing selector, you'll have nice, maintainable object, can use like:
mypage.placeorderbutton().click();
just consider.
Comments
Post a Comment