Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion javascript/atoms/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ bot.events.TouchEventFactory_.prototype.create = function (target, opt_args) {
} else if (strategy == bot.events.TouchEventStrategy_.INIT_TOUCH_EVENT) {
event = doc.createEvent('TouchEvent');
// Different browsers have different implementations of initTouchEvent.
if (event.initTouchEvent.length == 0) {
// if (event.initTouchEvent.length == 0) {
if (!goog.userAgent.product.IOS) {
// Chrome/Android.
event.initTouchEvent(touches, targetTouches, changedTouches,
this.type_, view, /*screenX*/ 0, /*screenY*/ 0, args.clientX,
Expand Down
2 changes: 2 additions & 0 deletions javascript/webdriver/atoms/exports/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ goog.exportSymbol('webdriver.atoms.inputs.mouseMove',
webdriver.atoms.inputs.mouseMove);
goog.exportSymbol('webdriver.atoms.inputs.sendKeys',
webdriver.atoms.inputs.sendKeys);
goog.exportSymbol('webdriver.atoms.inputs.tap',
webdriver.atoms.inputs.tap);
9 changes: 9 additions & 0 deletions javascript/webdriver/atoms/inject/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ closure_fragment(
],
)

closure_fragment(
name = "tap",
function = "webdriver.atoms.inject.action.tap",
module = "webdriver.atoms.inject.action",
deps = [
":action",
],
)

closure_fragment(
name = "clear-local-storage",
function = "webdriver.atoms.inject.storage.local.clear",
Expand Down
13 changes: 13 additions & 0 deletions javascript/webdriver/atoms/inject/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ webdriver.atoms.inject.action.click = function (element, opt_window) {
[element], opt_window);
};

/**
* Tap an element.
*
* @param {bot.inject.JsonElement} element The element to tap.
* @param {bot.inject.JsonWindow=} opt_window The optional window
* containing the element.
* @return {string} A stringified {@link bot.response.ResponseObject}.
* @see bot.action.tap
*/
webdriver.atoms.inject.action.tap = function (element, opt_window) {
return webdriver.atoms.inject.action.executeActionFunction_(bot.action.tap,
[element], opt_window);
};

/**
* JSON representation of a {@link bot.Mouse.State} object.
Expand Down
13 changes: 13 additions & 0 deletions javascript/webdriver/atoms/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ goog.provide('webdriver.atoms.inputs');

goog.require('bot.Keyboard');
goog.require('bot.Mouse');
goog.require('bot.Touchscreen');
goog.require('bot.action');
goog.require('bot.dom');
goog.require('goog.dom');
Expand Down Expand Up @@ -76,6 +77,18 @@ webdriver.atoms.inputs.click = function(element, opt_state) {
return mouse.getState();
};

/**
* Tap on an element.
*
* @param {?Element} element The element to tap.
*/
webdriver.atoms.inputs.tap = function(element) {
var touchScreen = new bot.Touchscreen();
if (!element) {
throw Error('No element to send keys to');
}
bot.action.tap(element, null, touchScreen);
};

/**
* Move the mouse to a specific element and/or coordinate location.
Expand Down