Skip to content

Commit

Permalink
[bidi][js] Add reload command
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Oct 31, 2023
1 parent 0291a70 commit f0b07fd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
26 changes: 26 additions & 0 deletions javascript/node/selenium-webdriver/bidi/browsingContext.js
Expand Up @@ -268,6 +268,32 @@ class BrowsingContext {
throw Error(result['error'])
}
}

async reload(ignoreCache = undefined, readinessState = undefined) {
if (
readinessState !== undefined &&
!['none', 'interactive', 'complete'].includes(readinessState)
) {
throw Error(
`Valid readiness states are 'none', 'interactive' & 'complete'. Received: ${readinessState}`
)
}

const params = {
method: 'browsingContext.reload',
params: {
context: this._id,
ignoreCache: ignoreCache,
wait: readinessState,
},
}
const navigateResult = (await this.bidi.send(params))['result']

return new NavigateResult(
navigateResult['url'],
navigateResult['navigation']
)
}
}

class NavigateResult {
Expand Down
32 changes: 32 additions & 0 deletions javascript/node/selenium-webdriver/test/bidi/bidi_test.js
Expand Up @@ -645,6 +645,38 @@ suite(
const result = await driver.getPageSource()
assert.equal(result.includes(userText), false)
})

it.skip('can reload a browsing context', async function () {
const id = await driver.getWindowHandle()
const browsingContext = await BrowsingContext(driver, {
browsingContextId: id,
})

const result = await browsingContext.navigate(
Pages.logEntryAdded,
'complete'
)

await browsingContext.reload()
assert.equal(result.navigationId, null)
assert(result.url.includes('/bidi/logEntryAdded.html'))
})

it.skip('can reload with readiness state', async function () {
const id = await driver.getWindowHandle()
const browsingContext = await BrowsingContext(driver, {
browsingContextId: id,
})

const result = await browsingContext.navigate(
Pages.logEntryAdded,
'complete'
)

await browsingContext.reload(undefined, 'complete')
assert.notEqual(result.navigationId, null)
assert(result.url.includes('/bidi/logEntryAdded.html'))
})
})

describe('Browsing Context Inspector', function () {
Expand Down

0 comments on commit f0b07fd

Please sign in to comment.