diff --git a/javascript/atoms/test/window_size_test.html b/javascript/atoms/test/window_size_test.html index 8c9c6acd1a199..2b85a1ff5b9d6 100644 --- a/javascript/atoms/test/window_size_test.html +++ b/javascript/atoms/test/window_size_test.html @@ -69,8 +69,21 @@ return; } var size = new goog.math.Size(350, 450); + var done = assert.async(); + var start = new Date().getTime(); bot.window.setSize(size); - verifySize(assert, size); + var isIE = bot.userAgent.IE_DOC_9 || bot.userAgent.IE_DOC_PRE9; + (function poll() { + var actual = bot.window.getSize(); + if (isIE || + (actual.width === size.width && actual.height === size.height) || + new Date().getTime() - start > 2000) { + verifySize(assert, size); + done(); + return; + } + window.setTimeout(poll, 50); + })(); }); QUnit.test('setSizeUsingGetSize', function(assert) { diff --git a/javascript/selenium-webdriver/test/lib/webdriver_script_test.js b/javascript/selenium-webdriver/test/lib/webdriver_script_test.js index f1e4c632f1ad1..a1d260ae32e18 100644 --- a/javascript/selenium-webdriver/test/lib/webdriver_script_test.js +++ b/javascript/selenium-webdriver/test/lib/webdriver_script_test.js @@ -36,6 +36,14 @@ suite( }) describe('script()', function () { + async function waitForLogEntry(getLogEntry, message) { + await driver.wait(() => getLogEntry() != null, 5000, message) + } + + async function waitForLogText(logs, text) { + await driver.wait(() => logs.includes(text), 5000, `Timed out waiting for console log "${text}"`) + } + it('can listen to console log', async function () { let log = null const handler = await driver.script().addConsoleMessageHandler((logEntry) => { @@ -44,6 +52,7 @@ suite( await driver.get(Pages.logEntryAdded) await driver.findElement({ id: 'consoleLog' }).click() + await waitForLogEntry(() => log, 'Timed out waiting for console log entry') assert.equal(log.text, 'Hello, world!') assert.equal(log.realm, null) @@ -62,6 +71,7 @@ suite( await driver.get(Pages.logEntryAdded) await driver.findElement({ id: 'jsException' }).click() + await waitForLogEntry(() => log, 'Timed out waiting for JavaScript error log entry') assert.equal(log.text, 'Error: Not working') assert.equal(log.type, 'javascript') @@ -91,6 +101,7 @@ suite( await element.click() let revealed = driver.findElement({ id: 'revealed' }) await driver.wait(until.elementIsVisible(revealed), 5000) + await waitForLogEntry(() => message, 'Timed out waiting for DOM mutation') assert.strictEqual(message['attribute_name'], 'style') assert.strictEqual(message['current_value'], '') @@ -124,6 +135,7 @@ suite( }) await driver.get(Pages.logEntryAdded) + await waitForLogEntry(() => log, 'Timed out waiting for pinned script log entry') assert.equal(log.text, 'Hello!') }) @@ -138,6 +150,8 @@ suite( }) await driver.get(Pages.logEntryAdded) + await waitForLogText(logs, 'Hello') + await waitForLogText(logs, 'World') assert.ok(logs.includes('Hello'), `[${logs}] should contain "Hello"`) assert.ok(logs.includes('World'), `[${logs}] should contain "World"`) @@ -145,6 +159,7 @@ suite( logs.length = 0 await driver.get(Pages.logEntryAdded) + await waitForLogText(logs, 'World') assert.ok(logs.includes('World'), `[${logs}] should contain "World"`) assert.ok(!logs.includes('Hello'), `[${logs}] should not contain "Hello"`) })