Skip to content

Instantly share code, notes, and snippets.

@shogochiai
Created February 15, 2015 08:23
Show Gist options
  • Save shogochiai/32ac779d463fc6ccf9b4 to your computer and use it in GitHub Desktop.
Save shogochiai/32ac779d463fc6ccf9b4 to your computer and use it in GitHub Desktop.
cordova製のアプリからボタン押してスライドを操作する奴のsubscriver側
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
fs = require("fs");
Promise = webdriver.promise.Promise,
argv = require('argv');
var milkcocoa = MilkCocoa(""),
rightBtnServer = milkcocoa.dataStore("rbtn"),
leftBtnServer = milkcocoa.dataStore("lbtn");
argv.option([{
name: 'url',
type : "string",
short: 'u',
description : "操作するスライドのURL"
},{
name: 'right-selector',
type : "string",
short: 'r',
description :'スライド進行ボタンのセレクタ'
},{
name: 'left-selector',
type : "string",
short: 'l',
description :'スライド逆行ボタンのセレクタ'
}]);
var options = argv.run().options;
var chromeDriver = new webdriver.Builder()
.usingServer('http://localhost:4444/wd/hub')
.withCapabilities( webdriver.Capabilities.chrome() )
.build();
chromeDriver.get(options.url);
rightBtnServer.on("send", function(e){
chromeDriver.findElement(By.id(options.right-selector)).click();
});
leftBtnServer.on("send", function(e){
chromeDriver.findElement(By.id(options.left-selector)).click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment