1

I am trying to do a simple Protractor test on different browsers and I am encountering that it is failing on IE, but not on Chrome.

I am testing the angularjs application on http://juliemr.github.io/protractor-demo/ which is a simple calculator app.

The test consists on the following code:

describe('Protractor Demo App', function() {
  it('should add 2 numbers', function() {
    var i,j;
    var w=10000;
    var t=100;
    i=Math.floor((Math.random() * t) + 1);
    j=Math.floor((Math.random() * t) + 1);

    browser.sleep(w);
    browser.get('http://juliemr.github.io/protractor-demo/');
        browser.waitForAngular();

    element(by.model('first')).sendKeys(i);
    element(by.model('second')).sendKeys(j);
    element(by.id('gobutton')).click();

    console.log('Sent: ' + i.toString() + ' + ' + j.toString());
    var x = element.all(by.repeater('result in memory').column('value')).get(0).getText();
    expect(x).toEqual((i+j).toString());

And my config file is:

// conf.js
exports.config = {
        capabilities: {
        'browserName': 'internet explorer',
        'platform': 'ANY',
        'version': '11',
        'nativeEvents': false,
        'unexpectedAlertBehaviour': 'accept',
        'ignoreProtectedModeSettings': true,
        'enablePersistentHover': true,
        'disable-popup-blocking': true
    },
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
}

When I set this last one for Chrome, (ie, commenting the capabilities part), the test runs as a charm and test is OK. I see the chrome window popping up, script puts numbers in, clicks button, result appears, and window closes.

When I set for IE (uncommenting the capabilities part) and launch the script, an IE window pops up with the text "This is the initial start page for the WebDriver server." and stays there for a while. Afterwards I see the script putting numbers in, and it closes straight away, giving a failed test on the log, with the message:

  Message:
    Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator by.repeater("result in memory").column("value")
  Stack:
    NoSuchElementError: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator by.repeater("result in memory").column("value")

It seems like the "Go" button is not being clicked, but I do not understand why. Can anyone help me understand what is going on?

Thank you!

ggonmar
  • 760
  • 1
  • 7
  • 28
  • What is `.column('value')`? I haven't seen that syntax in protractor before – Gunderson Jun 01 '17 at 15:56
  • I am retrieving a list of tables, and in order to get one particular value of the table, column is used... I found it here: https://stackoverflow.com/questions/34135713/protractor-tests-get-values-of-table-entries – ggonmar Jun 01 '17 at 16:03
  • Oh interesting, thanks for that. So this same locator works in Chrome? What if you try waiting for at least 1 element to exist, something similar to this [solution](https://stackoverflow.com/a/34293470/6201042)? I know protractor and angular are supposed to sync, but might help. – Gunderson Jun 01 '17 at 16:06
  • How are you starting your IEDriver with the selenium server? What version are you using? – cnishina Jun 02 '17 at 02:08
  • I believe I updated it with webdriver-manager update --ie, and I believe it is launched by protractor when I launch the test (though I might be very well wrong since I am not 100% understanding the way the driver is called :/ Version is 3.4.0. However, correct me if I'm wrong, but if the browser is indeed launching, and the input fields are correctly being filled, shouldnt that prove that the driver is, to some extent at least, working? – ggonmar Jun 02 '17 at 07:59

1 Answers1

0

The odd thing is that this is working in Chrome. Initially I thought this was an IE issue as well; however, the code above has an issue. In the StackOverflow link listed above in your comment, the column method is used correctly. The column usage is shown here on the Protractor site.

The line of code that looks suspect:

var x = element.all(by.repeater('result in memory').column('value')).get(0).getText();

This should probably be:

var x = element.all(by.repeater('result in memory').column('result .value')).get(0).getText();

This example is pretty much the same code as the protractor-cookbook. I would check that out as well.

cnishina
  • 5,016
  • 1
  • 23
  • 40
  • Hi, The change you propose causes no change on behavior: Chrome test passed, IE failed. Furthermore, I tried the code on the protractor-cookbook you mentioned, and that one is also failing on IE and working on Chrome. It seems everything points to the IEDriver, or is it me? – ggonmar Jun 03 '17 at 17:06