nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.8k stars 1.31k forks source link

[Enhancement] browser.assert.attributePresent #2541

Open lusarz opened 3 years ago

lusarz commented 3 years ago

Is your feature request related to a problem? Please describe. I'd like to check whether an attribute is present on element.

Describe the solution you'd like browser.assert.attributePresent('.some-link', 'href');

Pieras2 commented 3 years ago

Isn't it equivalent of browser.assert.elementPresent(".some-class"); ?

lusarz commented 3 years ago

No, imagine HTML like:

<img src="img.jpg" alt="Girl with a jacket" class="some-class" />

and I want to check if it contains "alt" attribute: browser.assert.attributePresent(".some-class", "alt");

lusarz commented 3 years ago

I think I can prepare pull request for that

gravityvi commented 3 years ago

Hey @lusarz, can we use browser.expect.element(<selector>).to.have.attribute('attribute-name') or am I missing something here?