Created
July 3, 2014 01:39
-
-
Save Jonahss/149fe33b4776ca7fb853 to your computer and use it in GitHub Desktop.
click-and-type-with-appium
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
var wd = require('wd') | |
var safari = | |
{ | |
"appium-version": '1.1', | |
"platformName": "iOS", | |
"platformVersion": "7.0", | |
"deviceName": "iPhone Simulator", | |
"browserName": "Safari", | |
"device-orientation": "portrait" | |
} | |
var sauce = { | |
hostname: "ondemand.saucelabs.com", | |
port: 80, | |
username: process.env.SAUCE_USERNAME, | |
accessKey: process.env.SAUCE_ACCESS_KEY | |
} | |
var local = { | |
hostname: "localhost", | |
port: 4723 | |
} | |
var testSequence = function(driver, sequence){ | |
var ids = sequence.split(',') | |
for (var i = 0; i < ids.length; i++) { | |
if (ids[i][0] == 't'){ | |
driver.elementById(ids[i]).type('hi') | |
} else { | |
driver.elementById(ids[i]).click() | |
} | |
} | |
} | |
var testSequenceSync = function(driver, sequence){ | |
var ids = sequence.split(',') | |
var next = function(){ | |
if (!ids.length){ return; } | |
var id = ids.shift() | |
if (id[0] == 't'){ | |
driver.elementById(id).type('hi').then(function(){ | |
next(); | |
}) | |
} else { | |
driver.elementById(id).click().then(function(){ | |
next(); | |
}) | |
} | |
} | |
next(); | |
} | |
var sequence = "text1,button1,text4,button3" | |
driver = wd.promiseChainRemote(sauce) | |
driver.init(safari).fail(console.log).get('http://fiddle.jshell.net/fFFPY/5/show/light/').then(function(){ | |
testSequenceSync(driver, sequence) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment