mardi 26 avril 2016

Protractor: Test failing when values are equal to each other

Below is my protractor test that opens a dialog in an angular application. It adds correctly but the test fails even when the values are equal to each other.

I want to say it might have something to do with the whole ignoringSynchronization but then I run into the whole timeout waiting for the synchronization with the modal dialog that pops up or something.

The message is: Expected 'Potato' to equal 'Potato'. These are all just dummy values but yeah just to get the gist of it.

describe('someTest', function(){
// beforeEach(function(){
//     browser.get("url");

// })

it('Add Test', function(){
    browser.get("url");
    var testEle = element(by.model('ng-model'));
    testEle.$('[value="0"]').click();

    browser.waitForAngular();
    //grabbing first object from the ng-repeat
    testEle = element(by.repeater("ng-repeat").row(0));
    testEle.element(by.tagName('span')).click();

    //A modal dialog pops open with an input box so you can type stuff into it and will show options to auto complete
    //that you can click on

    //need this or else it will timeout waiting for angular to sync
    browser.ignoreSynchronization = true;


    var EC = protractor.ExpectedConditions;
    browser.wait(EC.elementToBeClickable(element(by.id('an_input_tag'))));
    testEle = element(by.id('an_input_tag'));
    testEle.sendKeys("Potat");
    browser.wait(EC.elementToBeClickable(element(by.id('input_auto_completes'))));
    testEle = element(by.id('input_auto_completes'));
    testEle.click();
    browser.wait(EC.elementToBeClickable(element(by.buttonText('Add'))));
    element(by.buttonText('Add')).click();

    browser.wait(EC.textToBePresentInElement(element(by.repeater("ng-repeat").row(0)), 'Potato'));
    testEle = element(by.repeater("ng-repeat").row(0)).element(by.className('className'));
    expect(testEle.getText()).toEqual('Potato');

 })
}

Aucun commentaire:

Enregistrer un commentaire