Ramtin Soltani
Ramtin Soltani

Reputation: 2710

How to set attribute of a webElement in Protractor?

I'm using Protractor 2 and want to change the class attribute of a webElement.

Pretend I have this menuWrapper element which I need to append show to its class attribute.

What is the easiest way to achieve this? Except for browser.executeScript().

Upvotes: 2

Views: 1359

Answers (1)

alecxe
alecxe

Reputation: 473873

Selenium WebDriver specification (which WebDriverJS and hence Protractor follow/use) does not have anything documented for setting an element's attribute, only for getting an element's attribute. In other words, you won't find anything built-in for this task.

Certainly, the easiest way to set an element's attribute would be to use executeScript().

Upvotes: 3

Related Questions