提交 02a89c2c 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

support(switch account): try to click the button if found (#636)

上级 91540132
......@@ -582,8 +582,14 @@ export class Bridge {
})
})
}
public async clickSwitchAccount(): Promise<boolean> {
log.verbose('PuppetWebBridge', 'clickSwitchAccount()')
return this.puppet.browser.clickSwitchAccount()
}
}
/* tslint:disable:jsdoc-format */
/* tslint:disable:max-line-length */
/**
......
......@@ -18,6 +18,7 @@
*/
import {
Builder,
By,
Capabilities,
IWebDriverOptionsCookie,
logging,
......@@ -52,7 +53,7 @@ promiseManager.USE_PROMISE_MANAGER = false
process.env['DBUS_SESSION_BUS_ADDRESS'] = '/dev/null'
export class BrowserDriver {
private driver: WebDriver
public driver: WebDriver
constructor(
private head: HeadName,
......@@ -429,6 +430,7 @@ export class BrowserDriver {
// export default BrowserDriver
export {
By,
IWebDriverOptionsCookie,
Session,
TargetLocator,
......
......@@ -35,6 +35,7 @@ import {
import {
BrowserDriver,
IWebDriverOptionsCookie,
By,
} from './browser-driver'
export interface BrowserSetting {
......@@ -494,6 +495,20 @@ export class Browser extends EventEmitter {
return dead
}
public async clickSwitchAccount(): Promise<boolean> {
log.verbose('PuppetWebBrowser', 'clickSwitchAccount()')
try {
const button = await this.driver.driver.findElement(By.linkText('Switch Account'))
button.click()
log.silly('PuppetWebBrowser', 'clickSwitchAccount() clicked!')
return true
} catch (e) {
log.silly('PuppetWebBrowser', 'clickSwitchAccount() button not found: %s', e && e.message || e)
return false
}
}
public addCookie(cookies: IWebDriverOptionsCookie[]): Promise<void>
public addCookie(cookie: IWebDriverOptionsCookie): Promise<void>
......
......@@ -119,6 +119,11 @@ export class PuppetWeb extends Puppet {
}
log.verbose('PuppetWeb', 'initBridge() done')
const clicked = await this.bridge.clickSwitchAccount()
if (clicked) {
log.verbose('PuppetWeb', 'init() bridge.clickSwitchAccount() clicked')
}
/**
* state must set to `live`
* before feed Watchdog
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册