it('go to google', async () => {
await browser.url('http://www.google.com');
const elem = await $('#SIvCob');
expect(await elem.getText()).toContain('Google offered in');
expect(elem).toHaveTextContaining('Google offered in');
})
The assertions should be equivalent, but actually, the second resolves to false.
[0-0] {
passed: true,
assertion: {
matcherName: 'toContain',
passed: true,
message: '',
error: undefined,
errorForStack: undefined,
actual: 'Google offered in: Français',
expected: 'Google offered in'
}
}
[0-0] {
passed: undefined,
assertion: {
matcherName: 'toHaveTextContaining',
passed: undefined,
message: "Expected Element({ sessionId: '276a5be58236ede817a24f4e00b3ef3c', elementId: '283acefc-74ce-4fea-9699-ffb41e49b0ba', element-6066-11e4-a52e-4f735466cecf: '283acefc-74ce-4fea-9699-ffb41e49b0ba', selector: '#SIvCob', parent: Browser({ sessionId: '276a5be58236ede817a24f4e00b3ef3c', capabilities: Object({ acceptInsecureCerts: true, browserName: 'chrome', browserVersion: '90.0.4430.85', chrome: Object({ chromedriverVersion: '90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429})', userDataDir: '/var/folders/x8/c58l8cz10x7gkpf7wy1hxcv00000gn/T/.com.google.Chrome.CscXpN' }), goog:chromeOptions: Object({ debuggerAddress: 'localhost:52180' }), networkConnectionEnabled: false, pageLoadStrategy: 'normal', platformName: 'mac os x', proxy: Object({ }), setWindowRect: true, strictFileInteractability: false, timeouts: Object({ implicit: 0, pageLoad: 300000, script: 30000 }), unhandledPromptBehavior: 'dismiss and notify', webauthn:extension:largeBlob: true, webauthn:virtualA ... to have text containing 'Google offered in'.",
error: undefined,
errorForStack: undefined,
actual: Element {
sessionId: '276a5be58236ede817a24f4e00b3ef3c',
elementId: '283acefc-74ce-4fea-9699-ffb41e49b0ba',
'element-6066-11e4-a52e-4f735466cecf': '283acefc-74ce-4fea-9699-ffb41e49b0ba',
selector: '#SIvCob',
parent: [Browser],
emit: [Function: bound ],
isReactElement: false,
addCommand: [Function (anonymous)],
overwriteCommand: [Function (anonymous)]
},
expected: 'Google offered in'
}
}
[0-0] {
passed: false,
assertion: {
matcherName: '',
passed: false,
expected: '',
actual: '',
error: {
matcherName: 'toHaveTextContaining',
message: "Expected Element({ sessionId: '276a5be58236ede817a24f4e00b3ef3c', elementId: '283acefc-74ce-4fea-9699-ffb41e49b0ba', element-6066-11e4-a52e-4f735466cecf: '283acefc-74ce-4fea-9699-ffb41e49b0ba', selector: '#SIvCob', parent: Browser({ sessionId: '276a5be58236ede817a24f4e00b3ef3c', capabilities: Object({ acceptInsecureCerts: true, browserName: 'chrome', browserVersion: '90.0.4430.85', chrome: Object({ chromedriverVersion: '90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429})', userDataDir: '/var/folders/x8/c58l8cz10x7gkpf7wy1hxcv00000gn/T/.com.google.Chrome.CscXpN' }), goog:chromeOptions: Object({ debuggerAddress: 'localhost:52180' }), networkConnectionEnabled: false, pageLoadStrategy: 'normal', platformName: 'mac os x', proxy: Object({ }), setWindowRect: true, strictFileInteractability: false, timeouts: Object({ implicit: 0, pageLoad: 300000, script: 30000 }), unhandledPromptBehavior: 'dismiss and notify', webauthn:extension:largeBlob: true, webauthn:virtualA ... to have text containing 'Google offered in'.",
stack: "Error: Expected Element({ sessionId: '276a5be58236ede817a24f4e00b3ef3c', elementId: '283acefc-74ce-4fea-9699-ffb41e49b0ba', element-6066-11e4-a52e-4f735466cecf: '283acefc-74ce-4fea-9699-ffb41e49b0ba', selector: '#SIvCob', parent: Browser({ sessionId: '276a5be58236ede817a24f4e00b3ef3c', capabilities: Object({ acceptInsecureCerts: true, browserName: 'chrome', browserVersion: '90.0.4430.85', chrome: Object({ chromedriverVersion: '90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429})', userDataDir: '/var/folders/x8/c58l8cz10x7gkpf7wy1hxcv00000gn/T/.com.google.Chrome.CscXpN' }), goog:chromeOptions: Object({ debuggerAddress: 'localhost:52180' }), networkConnectionEnabled: false, pageLoadStrategy: 'normal', platformName: 'mac os x', proxy: Object({ }), setWindowRect: true, strictFileInteractability: false, timeouts: Object({ implicit: 0, pageLoad: 300000, script: 30000 }), unhandledPromptBehavior: 'dismiss and notify', webauthn:extension:largeBlob: true, webauthn:virtualA ... to have text containing 'Google offered in'.\n" +
' at <Jasmine>\n' +
' at Spec.addExpectationResult (/Users/thiagolima/Documents/neo/member-portal/node_modules/@wdio/jasmine-framework/build/index.js:296:32)\n' +
' at <Jasmine>\n' +
' at UserContext.<anonymous> (/Users/thiagolima/Documents/neo/member-portal/test/wdio/tests/login.test.ts:32:18)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:93:5)',
passed: undefined,
expected: 'Google offered in',
actual: [Element]
}
}
}