Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion javascript/atoms/test/window_size_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
done();
return;
}
window.setTimeout(poll, 50);
})();
});

QUnit.test('setSizeUsingGetSize', function(assert) {
Expand Down
15 changes: 15 additions & 0 deletions javascript/selenium-webdriver/test/lib/webdriver_script_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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)
Expand All @@ -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')
Expand Down Expand Up @@ -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'], '')
Expand Down Expand Up @@ -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!')
})
Expand All @@ -138,13 +150,16 @@ 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"`)

await driver.script().unpin(id)

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"`)
})
Expand Down
Loading