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)
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.