cabbie-sync
Version:
A synchronous webdriver client
97 lines (84 loc) • 2.47 kB
Flow
/**
* @flow
* This file is generated automatically, run npm run build to re-generate.
**/
import type { BrowserOrientation } from './enums/browser-orientations';
import type Driver from './driver';
import type { Options } from './flow-types/options';
import ActiveWindow from './active-window';
import addDebugging from './add-debugging';
import BaseClass from './base-class';
import CookieStorage from './cookie-storage';
import IME from './ime';
import LocalStorage from './local-storage';
import SessionStorage from './session-storage';
import WindowHandle from './window-handle';
/*
* Browser accessor class
*/
class Browser extends BaseClass {
/*
* The currently active window. This has most of the methods to interact with
* the the current page.
*/
activeWindow: ActiveWindow;
/*
* Get the IME object.
*/
ime: IME;
/*
* Get the Cookie-Storage object.
*/
cookieStorage: CookieStorage;
/*
* Get the Local-Storage object.
*/
localStorage: LocalStorage;
/*
* Get the Session-Storage object.
*/
sessionStorage: SessionStorage;
constructor(driver: Driver, options: Options) {
super(driver);
this.activeWindow = new ActiveWindow(this.driver, options);
this.ime = new IME(this.driver);
this.cookieStorage = new CookieStorage(this.driver);
this.localStorage = new LocalStorage(this.driver);
this.sessionStorage = new SessionStorage(this.driver);
}
/*
* Get an array of windows for all available windows
*/
getWindows(): Array<WindowHandle> {
const windowHandles = this.requestJSON('GET', '/window_handles');
return windowHandles.map(windowHandle => {
return new WindowHandle(this.driver, windowHandle);
});
}
/*
* Get the current browser orientation
*/
getOrientation(): BrowserOrientation {
return this.requestJSON('GET', '/orientation');
}
/*
* Get the current browser orientation
*/
setOrientation(orientation: BrowserOrientation): void {
this.requestJSON('POST', '/orientation', { orientation });
}
/*
* Get the current geo location
*/
getGeoLocation(): { latitude: number; longitude: number; altitude: number; } {
return this.requestJSON('GET', '/location');
}
/*
* Set the current geo location
*/
setGeoLocation(loc: { latitude: number; longitude: number; altitude: number; }): void {
this.requestJSON('POST', '/location', loc);
}
}
addDebugging(Browser);
export default Browser;