Skip to content

Instantly share code, notes, and snippets.

@yzen
Created October 24, 2014 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yzen/0c154d8d9f1135d684c5 to your computer and use it in GitHub Desktop.
Save yzen/0c154d8d9f1135d684c5 to your computer and use it in GitHub Desktop.
/*
--- a/apps/calendar/test/marionette/lib/calendar.js
+++ b/apps/calendar/test/marionette/lib/calendar.js
@@ -10,7 +10,9 @@ var AdvancedSettings = require('./views/advanced_settings'),
MonthDay = require('./views/month_day'),
ReadEvent = require('./views/read_event'),
Settings = require('./views/settings'),
- Week = require('./views/week');
+ Week = require('./views/week'),
+ AccessibilityHelper = require(
+ '../../../../../tests/js-marionette/accessibility_helper.js');
function Calendar(client) {
this.client = client.scope({ searchTimeout: 5000 });
@@ -27,6 +29,7 @@ function Calendar(client) {
this.readEvent = new ReadEvent(client);
this.settings = new Settings(client);
this.week = new Week(client);
+ this.accessibilityHelper = new AccessibilityHelper(client);
}
module.exports = Calendar;
@@ -149,6 +152,12 @@ Calendar.prototype = {
return this;
},
+ a11yClickToday: function() {
+ this.accessibilityHelper.click(this.client.findElement(
+ '#view-selector a[href="#today"]'));
+ return this;
+ },
+
*/
//=============
'use strict';
/* global require, module */
var fs = require('fs');
var atom = fs.readFileSync('./tests/atoms/accessibility.js', {
encoding: 'utf-8'
});
var AccessibilityHelper = function(client) {
function run_async_script(method, args) {
client.setScriptTimeout(10000);
var value = client.executeAsyncScript(
atom + 'return Accessibility.' + method + '(arguments);\n', args);
if (!value) {
return;
}
if (value.error) {
throw new Error('accessibility.js error: '+ value.error);
} else {
return value.result;
}
}
this.click = function(element) {
run_async_script('click', [element]);
};
this.isHidden = function(element) {
return run_async_script('isHidden', [element]);
};
this.isVisible = function(element) {
return run_async_script('isVisible', [element]);
};
this.isDisabled = function(element) {
return run_async_script('isDisabled', [element]);
};
this.wheel = function(element, direction) {
client.executeScript(
atom + 'Accessibility.wheel(arguments);\n', [element, direction]);
};
this.getName = function(element) {
return run_async_script('getName', [element]);
};
this.getRole = function(element) {
return run_async_script('getRole', [element]);
};
this.dispatchEvent = function() {
client.executeScript('window.wrappedJSObject.dispatchEvent(new ' +
'CustomEvent("accessibility-action"))\n');
};
};
module.exports = AccessibilityHelper;
//=============
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment