【发布时间】:2014-12-12 09:38:18
【问题描述】:
我有一个使用 cordova facebook 插件的 ionic/angularjs/cordova 应用程序。我有带有黄瓜和量角器设置的 appium,我可以在模拟器中测试应用程序上的所有内容。在应用程序本身中,我设置了 facebook 身份验证,我正在尝试在 iOS 模拟器上进行测试。
如果你看下面这一步
And I input my facebook credentials
应用程序将重定向到 facebook 移动网络,等待浏览器加载,然后无限刷新自身。
当我在科尔多瓦应用程序重定向到 safari 上的 facebook 后 console.log 浏览器 url 时,该 url 是应用程序的本地文件路径,现在是 facebook 的浏览器 url。
config.js
exports.config = {
capabilities: {
browserName: 'iOS',
app: '/Users/username/Projects/app-directory/platforms/ios/build/emulator/appname.app',
deviceName: 'iPhone Simulator',
'appium-version': '1.3.0-beta1',
version: '8.0',
platformName: 'iOS',
platformVersion: '8.0',
autoWebview: true,
autoWebviewTimeout: 10
},
allScriptsTimeout: 30000,
seleniumAddress: 'http://localhost:4723/wd/hub',
baseUrl: 'http://localhost:8100',
onPrepare: function() {
var wd = require('wd'),
_ = require('underscore'),
wdBridge = require('wd-bridge')(protractor, wd);
wdBridge.initFromProtractor(exports.config);
},
framework: 'cucumber',
cucumberOpts: {
require: '../features/**/*.js',
format: 'pretty'
},
specs: [ '../features/*.feature' ]
};
root.feature
Feature: Root Screen
As a user who is not logged in
I want to be greeted with a menu screen
So that I know where to sign up or login
Scenario: Successfully logging into the app through facebook
Given I am a user on facebook
When I click on the facebook button
And I input my facebook credentials
And I accept the facebook permissions
Then I should be at the home screen
根步骤
var rootSteps = function() {
this.Given(/^I am a user on facebook$/, function (done) {
this.app.createFbUser().then(done); // helper that returns a promise and creates a fb test user object and sets it to this.app.fbUser;
});
this.When(/^I click on the facebook button$/, function (done) {
browser.driver.findElement(by.css('[ng-click="fbLogin()"]')).click().then(done);
});
this.When(/^I input my facebook credentials$/, function (done) {
browser.sleep( 8000 ); // wait for facebook to completely load
wdBrowser.contexts().then(function(ctxs) {
var webCtx = _(ctxs).find(function(ctx) { return ctx.match(/WEBVIEW/)});
wdBrowser.context(webCtx) ;
}).then(function() {
browser.ignoreSynchronization = true
var emailElem = browser.driver.findElement(by.name('email'));
var passwordElem = browser.driver.findElement(by.name('password'));
var submitElem = browser.driver.findElement(by.name('login'));
emailElem.sendKeys(this.app.fbUser.email);
passwordElem.sendKeys(this.app.fbUser.password);
submitElem.click().then(done);
});
});
this.When(/^I accept the facebook permissions$/, function (done) {
done.pending();
});
this.Then(/^I should be at the home screen$/, function (done) {
done.pending();
})
};
module.exports = rootSteps;
这是来自 Appium 的错误日志。
info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP","WEBVIEW_1"],"sessionId":"a93509a3-3cce-4f03-be58-c59474b40e92"}
info: <-- GET /wd/hub/session/a93509a3-3cce-4f03-be58-c59474b40e92/contexts 200 2.140 ms - 98 {"status":0,"value":["NATIVE_APP","WEBVIEW_1"],"sessionId":"a93509a3-3cce-4f03-be58-c59474b40e92"}
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] Got a blank data response from debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] {"__argument" {"WIRApplicationIdentifierKey":"PID:34459","WIRIsApplicationProxyKey":false,"WIRApplicationNameKey":"Safari","WIRApplicationBundleIdentifierKey":"com.apple.mobilesafari","WIRIsApplicationActiveKey":1},"__selector":"_rpc_applicationConnected:"}
info: [REMOTE] We were notified that we connected to possibly the wrong application. Ignoring for now and hoping we're going to retry looking for apps
【问题讨论】:
标签: facebook angularjs cordova protractor appium