0

I'm running some angular e2e tests with protractor and getting a failing expectation.

expect: Expected [ 'Integration Test Acquirer Automatically generated EUR,GBP,USD activated' ] to contain 'Integration Test Acquirer Automatically generated EUR'.

The code I use in this expectation is:

expect(processingPathListElement.count()).toEqual(1);

expect(processingPathListElement.getText()).toContain('Integration Test Acquirer Automatically generated EUR');

So the text "Integration Test Acquirer Automatically generated EUR" is actually contained in "Integration Test Acquirer Automatically generated EUR,GBP,USD".

I should mention that this test only fails when I use sharding of the tests (running several instances of a browser instead of only one, and dividing the tests among them). The tests are running in 5 instances of firefox. Another thing is that I'm using contain instead of looking at the entire string and using the matcher "toEqual" because when I run the tests sharded the space in between the currencies (should be "EUR, GBP, USD" ends up being "EUR,GBP,USD") is removed. I don't care too much about the second problem but I do care about the 1st. And again this problem only manifests itself when I run the tests with the config:

capabilities: {
    'browserName': 'firefox',
    shardTestFiles: true,
    maxInstances: 5
},

If I remove the shardTestFiles: true the tests pass.

Here is the entire information on the failing test:

expect: Expected [ 'Integration Test Acquirer Automatically generated EUR,GBP,USD activated' ] to contain 'Integration Test Acquirer Automatically generated EUR'. Error: Failed expectation at null.<anonymous> (/Users/bamboo/bamboo-home/xml-data/build-dir/IOG-TESTFE61-JOB1/test/e2e/merchants/merchant/merchantMPOSSpec.js:177:69) at /usr/local/lib/node_modules/protractor/node_modules/jasminewd/index.js:94:14 at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1640:20) at webdriver.promise.ControlFlow.runEventLoop_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1505:8) at wrapper [as _onTimeout] (timers.js:252:14) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)expect: Expected [ 'Integration Test Acquirer Automatically generated EUR,GBP,USD activated' ] to contain 'GBP'. Error: Failed expectation at null.<anonymous> (/Users/bamboo/bamboo-home/xml-data/build-dir/IOG-TESTFE61-JOB1/test/e2e/merchants/merchant/merchantMPOSSpec.js:178:69) at /usr/local/lib/node_modules/protractor/node_modules/jasminewd/index.js:94:14 at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1640:20) at webdriver.promise.ControlFlow.runEventLoop_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1505:8) at wrapper [as _onTimeout] (timers.js:252:14) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)expect: Expected [ 'Integration Test Acquirer Automatically generated EUR,GBP,USD activated' ] to contain 'USD activated'. Error: Failed expectation at null.<anonymous> (/Users/bamboo/bamboo-home/xml-data/build-dir/IOG-TESTFE61-JOB1/test/e2e/merchants/merchant/merchantMPOSSpec.js:179:69) at /usr/local/lib/node_modules/protractor/node_modules/jasminewd/index.js:94:14 at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1640:20) at webdriver.promise.ControlFlow.runEventLoop_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1505:8) at wrapper [as _onTimeout] (timers.js:252:14) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132
pcatre
  • 1,304
  • 2
  • 16
  • 24

1 Answers1

4

Your selector (processingPathListElement) returns more than one element, that's why the expectation fails. It is not a "toContain" issue.

This should be a comment, I guess, but no rights for me.

Delian Mitankin
  • 3,691
  • 26
  • 24
  • You are right. Thank you very much. It was a stupid distraction on my part because I new the list only contained one element and it works for other cases that are the same as this one (even in sharded tests). And this test would pass if the tests were not sharded which is very confusing and made me think the problem was elsewhere. Also, the way the expectation failed seems strange. It should say it could not do it, but to present both texts and say one is not contained in the other (when it actually is). – pcatre Feb 10 '15 at 10:24