我有一个使用cordova facebook插件的ionic / angularjs / cordova应用程序。我有黄瓜和量角器设置的appium,我可以在模拟器中测试应用程序上的所有内容。在应用程序本身我有facebook身份验证设置,我试图在iOS模拟器上测试它。
如果你看下面的这一步
And I input my facebook credentials
该应用程序将重定向到Facebook移动网络,等待浏览器加载,然后将无限刷新自己。
当我在cordova应用程序重定向到safari上的facebook后,我在console.log浏览器网址时,该网址是应用程序的本地文件路径,现在是facebook的浏览器网址。
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
答案 0 :(得分:0)
目前,这是不可能的。根据Appium团队的说法,xcode工具会加载应用程序,目前无法更改软件包ID。