Last active
December 17, 2015 20:48
-
-
Save asmod3us/5669917 to your computer and use it in GitHub Desktop.
How to issue touch and other gestures with appium in a hybrid app?
This file contains hidden or 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
| "use strict"; | |
| var wd = require("wd"), | |
| should = require("should"), | |
| appURL = "http://appium.s3.amazonaws.com/WebViewApp6.0.app.zip"; | |
| // Instantiate a new browser sessoin | |
| var browser = wd.remote("localhost", 4723); | |
| // See whats going on | |
| browser.on('status', function(info) { | |
| console.log('\x1b[36m%s\x1b[0m', info); | |
| }); | |
| browser.on('command', function(meth, path, data) { | |
| console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || ''); | |
| }); | |
| // Run the test | |
| browser | |
| .chain() | |
| .init({ | |
| device: 'iPhone Simulator' | |
| , name: "Appium Hybrid App: with WD" | |
| , platform:'Mac 10.8' | |
| , app: appURL | |
| , version: '' | |
| , browserName: '' | |
| }) | |
| .windowHandles(function(err, handles) { | |
| handles.length.should.be.above(0); | |
| browser.window(handles[0], function() { | |
| browser.elementById('i_am_an_id', function(err, el) { | |
| should.not.exist(err); | |
| el.text(function(err, text) { | |
| text.should.eql("I am a div"); | |
| browser.elementById('submit', function(err, submit) { | |
| should.not.exist(err); | |
| should.exist(submit); | |
| // submit.click(function() { using click works | |
| // Q: What to put here for gestures on dom elements? | |
| var opts = { x: 0.5, y: 0.5, element: submit }; | |
| browser.execute('mobile: tap', [ opts ], function(err) { | |
| should.not.exist(err); | |
| browser.execute("mobile: leaveWebView", function() { | |
| browser.quit(); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment