This repository has been archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
152 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Copyright 2014-2015, Yahoo! Inc. | ||
// Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms. | ||
|
||
var sleep = require('sleep.js'); | ||
|
||
var DriverAdapter = require('./driverAdapter'); | ||
|
||
/** | ||
* @class TaxiAdapter | ||
* @extends DriverAdapter | ||
*/ | ||
var TaxiAdapter = DriverAdapter.extend( | ||
|
||
{ | ||
/** | ||
* Initializes the driver-adapter | ||
* | ||
* @method initialize | ||
*/ | ||
initialize: function () { | ||
// Nothing by default | ||
}, | ||
|
||
|
||
/** | ||
* Get the driver | ||
* | ||
* @method getDriver | ||
* @return {Browser} | ||
*/ | ||
getDriver: function () { | ||
return this.driver; | ||
}, | ||
|
||
|
||
/** | ||
* Gets the current url of the session window | ||
* | ||
* @method getCurrentUrl | ||
* @return {string} | ||
*/ | ||
getCurrentUrl: function () { | ||
return this.getPageContext().navigator().getUrl(); | ||
}, | ||
|
||
/** | ||
* Gets the current page context | ||
* | ||
* @method getPageContext | ||
* @return {Element} | ||
*/ | ||
getPageContext: function () { | ||
return this.getDriver().browser().activeWindow(); | ||
}, | ||
|
||
/** | ||
* Navigates to the supplied url | ||
* | ||
* @method navigateTo | ||
* @param {string} url | ||
*/ | ||
navigateTo: function (url) { | ||
return this.getPageContext().navigator().navigateTo(url); | ||
}, | ||
|
||
/** | ||
* Number of milliseconds to wait before moving on | ||
* | ||
* @method sleep | ||
* @param {int} waitInMs | ||
*/ | ||
sleep: function (waitInMs) { | ||
return sleep(waitInMs); | ||
}, | ||
|
||
/** | ||
* Takes a screenshot of the current session window | ||
* | ||
* @method takeScreenshot | ||
* @return {Buffer} | ||
*/ | ||
takeScreenshot: function () { | ||
return this.getPageContext().takeScreenshot(); | ||
}, | ||
|
||
/** | ||
* Executes JavaScript code | ||
* | ||
* @method executeScript | ||
* @param {string} code | ||
* @param {string[]} [args] | ||
* @return {*} | ||
*/ | ||
executeScript: function (code, args) { | ||
return this.getPageContext().execute(code, args); | ||
}, | ||
|
||
/** | ||
* Gets the first element that applies to the supplied selector with the selector-type | ||
* | ||
* @method getElement | ||
* @param {object} context | ||
* @param {string} selector | ||
* @param {string} [selectorType='css selector'] | ||
* @return {Element} | ||
*/ | ||
getElement: function (context, selector, selectorType) { | ||
return context.getElement(selector, selectorType); | ||
}, | ||
|
||
/** | ||
* Gets all elements that apply to the supplied selector with the selector-type | ||
* | ||
* @method getElements | ||
* @param {object} context | ||
* @param {string} selector | ||
* @param {string} [selectorType='css selector'] | ||
* @return {Element[]} | ||
*/ | ||
getElements: function (context, selector, selectorType) { | ||
return context.getElements(selector, selectorType); | ||
} | ||
}, | ||
|
||
{ | ||
/** | ||
* @property TYPE | ||
* @type {string} | ||
* @static | ||
*/ | ||
TYPE: 'TaxiAdapter' | ||
}); | ||
|
||
module.exports = TaxiAdapter; |