Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Commit

Permalink
➕ page: add bringToFront() (close #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepsweet committed Aug 18, 2018
1 parent 36bfba2 commit e8b9be4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/api/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class Page extends EventEmitter {
}))
}

async bringToFront () {
return this._send('WebDriver:SwitchToWindow', {
name: this._id,
focus: true
})
}

browser () {
return this._browser
}
Expand Down
24 changes: 24 additions & 0 deletions test/api/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,30 @@ test('Page: `$$()`', testWithFirefox(async (t) => {
)
}))

test('Page: `bringToFront()`', testWithFirefox(async (t) => {
const browser = await foxr.connect()

const page1 = await browser.newPage()
await page1.setContent('<title>page1</title>')

const page2 = await browser.newPage()
await page2.setContent('<title>page2</title>')

t.equal(
await page1.title(),
'page2',
'should perform actions only with current page'
)

await page1.bringToFront()

t.equal(
await page1.title(),
'page1',
'should activate page'
)
}))

test('Page: `browser()`', testWithFirefox(async (t) => {
const browser = await foxr.connect()
const page = await browser.newPage()
Expand Down

0 comments on commit e8b9be4

Please sign in to comment.