Skip to content

Commit f0b07fd

Browse files
committed
[bidi][js] Add reload command
1 parent 0291a70 commit f0b07fd

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

javascript/node/selenium-webdriver/bidi/browsingContext.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,32 @@ class BrowsingContext {
268268
throw Error(result['error'])
269269
}
270270
}
271+
272+
async reload(ignoreCache = undefined, readinessState = undefined) {
273+
if (
274+
readinessState !== undefined &&
275+
!['none', 'interactive', 'complete'].includes(readinessState)
276+
) {
277+
throw Error(
278+
`Valid readiness states are 'none', 'interactive' & 'complete'. Received: ${readinessState}`
279+
)
280+
}
281+
282+
const params = {
283+
method: 'browsingContext.reload',
284+
params: {
285+
context: this._id,
286+
ignoreCache: ignoreCache,
287+
wait: readinessState,
288+
},
289+
}
290+
const navigateResult = (await this.bidi.send(params))['result']
291+
292+
return new NavigateResult(
293+
navigateResult['url'],
294+
navigateResult['navigation']
295+
)
296+
}
271297
}
272298

273299
class NavigateResult {

javascript/node/selenium-webdriver/test/bidi/bidi_test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,38 @@ suite(
645645
const result = await driver.getPageSource()
646646
assert.equal(result.includes(userText), false)
647647
})
648+
649+
it.skip('can reload a browsing context', async function () {
650+
const id = await driver.getWindowHandle()
651+
const browsingContext = await BrowsingContext(driver, {
652+
browsingContextId: id,
653+
})
654+
655+
const result = await browsingContext.navigate(
656+
Pages.logEntryAdded,
657+
'complete'
658+
)
659+
660+
await browsingContext.reload()
661+
assert.equal(result.navigationId, null)
662+
assert(result.url.includes('/bidi/logEntryAdded.html'))
663+
})
664+
665+
it.skip('can reload with readiness state', async function () {
666+
const id = await driver.getWindowHandle()
667+
const browsingContext = await BrowsingContext(driver, {
668+
browsingContextId: id,
669+
})
670+
671+
const result = await browsingContext.navigate(
672+
Pages.logEntryAdded,
673+
'complete'
674+
)
675+
676+
await browsingContext.reload(undefined, 'complete')
677+
assert.notEqual(result.navigationId, null)
678+
assert(result.url.includes('/bidi/logEntryAdded.html'))
679+
})
648680
})
649681

650682
describe('Browsing Context Inspector', function () {

0 commit comments

Comments
 (0)