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

Commit

Permalink
🛠 page: don't activate page automatically on every action
Browse files Browse the repository at this point in the history
  • Loading branch information
deepsweet committed Aug 18, 2018
1 parent aee3c81 commit 36bfba2
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/api/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ class Page extends EventEmitter {
this._send = arg.send
}

private async _switchToPage () {
return this._send('WebDriver:SwitchToWindow', {
name: this._id
})
}

async $ (selector: string) {
await this._switchToPage()

try {
type TResult = {
value: {
Expand All @@ -62,8 +54,6 @@ class Page extends EventEmitter {
}

async $$ (selector: string) {
await this._switchToPage()

type TResult = {
ELEMENT: string
}
Expand All @@ -84,15 +74,12 @@ class Page extends EventEmitter {
}

async close () {
await this._switchToPage()
await this._send('WebDriver:ExecuteScript', {
script: 'window.close()'
})
}

async content (): Promise<string> {
await this._switchToPage()

type TResult = {
value: string
}
Expand All @@ -103,8 +90,6 @@ class Page extends EventEmitter {
}

async evaluate (target: TStringifiableFunction | string, ...args: TJsonValue[]): Promise<TJsonValue> {
await this._switchToPage()

type TResult = {
value: {
error: string | null,
Expand Down Expand Up @@ -152,13 +137,10 @@ class Page extends EventEmitter {
}

async goto (url: string) {
await this._switchToPage()
await this._send('WebDriver:Navigate', { url })
}

async screenshot (options: { path?: string } = {}): Promise<Buffer> {
await this._switchToPage()

const result = await this._send('WebDriver:TakeScreenshot', {
full: true,
hash: false
Expand All @@ -173,17 +155,13 @@ class Page extends EventEmitter {
}

async setContent (html: string) {
await this._switchToPage()

return this._send('WebDriver:ExecuteScript', {
script: 'document.documentElement.innerHTML = arguments[0]',
args: [html]
})
}

async title (): Promise<string> {
await this._switchToPage()

const result = await this._send('WebDriver:GetTitle')

return result.value
Expand Down

0 comments on commit 36bfba2

Please sign in to comment.