• Slider Banner

    Prepare for

    Technical Interview

    Over .1 Million+ Interview Questions for different profiles

    Read More
  • Slider Banner

    Join the

    Programming World

    Learn about top programming languages, tools and frameworks.

    Read More
  • Slider Banner

    Prepare with

    Certification MCQ

    Practice for certification from 1000+ multiple choice questions.

    Read More

How to verify whether an element is enabled or not?

To verify whether an element is enabled or not, we use isEnabled() method in Protractor. isEnabled() method returns a Boolean value based on the state of the element. It returns true if the element is enabled and false if the element is not enabled.

How to cancel Alert in Protractor?

By using dismiss() method of Alerts class, we cancel or close alerts in Protractor.

Note: We have to switch the control to the alert using switchTo().alert() before cancel the alert.

browser.switchTo().alert().dismiss()

How to accept Alert in Protractor?

By using accept() method of Alerts class, we accept Alerts in Protractor.

Note: We have to switch the control to the alert using switchTo().alert() before accepting the alert.

browser.switchTo().alert().accept()

How to get text from a textbox in Protractor?

By using getAttribute method by passing argument as value. getAttribute() method returns a promise which contains String:

Example

element(by.xpath("text box xpath").getAttribute("value")).then(function(textValue)
{
    console.log(textValue)
});
Subscribe to