1

In MEAN stack project I am using Selenium webdriver for frontend UI testing.

I have a field which is non editable. I have attached an image

Image

How can I test this field making sure it cannot be edited?


    it('not edit the field', () => {
        login('amazonuser');
        click(by.xpath('//mat-option[5]/span[contains(., "Amazon Id")]'));
        getElement(by.xpath('//id-number/div/mat-form-field[2]/div/div[1]/div/input')).sendKeys('0');
        logout();
    });

1 Answer 1

0

You assert that the disabled attribute is on the INPUT.

var input = element(by.xpath('//id-number/div/mat-form-field[2]/div/div[1]/div/input'))
expect(input.isEnabled()).toBe(true);

See the HTML docs.
See the Protractor docs.

3
  • I know but how should I code it using Selenium?
    – Hiyanneri
    Commented Mar 23, 2023 at 19:05
  • You should familiarize yourself with the Protractor docs. They have a lot of good examples. I've updated my answer with the code and a link to the docs.
    – JeffC
    Commented Mar 23, 2023 at 19:48
  • can you help with this - stackoverflow.com/questions/75922947/angular-testing-how-to-check-if-error-icon-is-absent-is-valid-data-is-passed
    – Hiyanneri
    Commented Apr 3, 2023 at 19:10

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.