Skip to content

Commit

Permalink
Merge branch 'trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
VietND96 authored Jan 8, 2024
2 parents cb27bd1 + a040c34 commit a2d8c65
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
19 changes: 19 additions & 0 deletions javascript/node/selenium-webdriver/bidi/browsingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,25 @@ class BrowsingContext {
throw Error(result['error'])
}
}

async traverseHistory(delta) {
const params = {
method: 'browsingContext.traverseHistory',
params: {
context: this._id,
delta: delta,
},
}
await this.bidi.send(params)
}

async forward() {
await this.traverseHistory(1)
}

async back() {
await this.traverseHistory(-1)
}
}

class NavigateResult {
Expand Down
33 changes: 33 additions & 0 deletions javascript/node/selenium-webdriver/test/bidi/bidi_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,39 @@ suite(
)
assert.equal(devicePixelRatio, 5)
})
xit('can navigate back in the browser history', async function () {
const id = await driver.getWindowHandle()
const browsingContext = await BrowsingContext(driver, {
browsingContextId: id,
})

await driver.get(Pages.formPage)

await driver.wait(until.elementLocated(By.id('imageButton')), 10000).submit()
await driver.wait(until.titleIs('We Arrive Here'), 5000)

await browsingContext.back()

await driver.wait(until.titleIs('We Leave From Here'), 5000)
})

xit('can navigate forward in the browser history', async function () {
const id = await driver.getWindowHandle()
const browsingContext = await BrowsingContext(driver, {
browsingContextId: id,
})

await driver.get(Pages.formPage)

await driver.wait(until.elementLocated(By.id('imageButton')), 10000).submit()
await driver.wait(until.titleIs('We Arrive Here'), 5000)

await browsingContext.back()
await driver.wait(until.titleIs('We Leave From Here'), 5000)

await browsingContext.forward()
await driver.wait(until.titleIs('We Arrive Here'), 5000)
})
})

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

0 comments on commit a2d8c65

Please sign in to comment.