2014-10-16 58 views
0

我有一個使用cordova facebook插件的離子/ angularjs/cordova應用程序。我有黃瓜和量角器安裝程序的appium,我可以在模擬器中測試應用程序中的所有內容。在應用程序本身我有Facebook身份驗證設置,我想在iOS模擬器上測試。無法使用Appium&Protractor從混合應用程序切換到com.mobile.safari

如果你看一下這個步驟如下

And I input my facebook credentials 

該應用程序將重定向到Facebook的移動網站,等待瀏覽器加載,然後將無限刷新自己。

當我console.log瀏覽器網址後,cordova應用程序重定向到Safari上的Facebook,該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 

回答

0

眼下這是目前不可能的。根據Appium團隊,xcode儀器加載應用程序,目前無法更改包ID。

相關問題