【问题标题】:Using Protractor + Appium + SauceLabs使用量角器 + Appium + SauceLabs
【发布时间】:2015-08-27 13:11:47
【问题描述】:

我一直在尝试针对 Mobile 自动化我的量角器测试。 我已经阅读了网络上的大多数博客,我找到了这个,它是 Appium with Saucelabs 的“官方”: https://docs.saucelabs.com/tutorials/appium/#mobile-web-application 我按照那里的说明进行操作,并将我的config.js 文件配置为这样

var testName = 'Testing'; //Change Project's name here in order to be identified in BrowserStack

exports.config = {
    // The address of a running selenium server.
    seleniumAddress: 'http://bmsoko:[redacted]@ondemand.saucelabs.com:80/wd/hub',
    // Capabilities to be passed to the webdriver instance.
    multiCapabilities: [{
        name: testName,
        'appium-version': '1.4.0',
        'browserName': 'Android',
        'deviceName': 'Android Emulator',
        'deviceOrientation': 'portrait',
        'platform': 'Linux',
        'version': '5.1',
        username: 'bmsoko',
        accessKey: '[redacted]'
    }],

    // Spec patterns are relative to the current working directly when
    // protractor is called.

    suites: {
        mobile: './././specs/mobile.js'
    },

    // Maximum number of total browser sessions to run. Tests are queued in
    // sequence if number of browser sessions is limited by this parameter.
    // Use a number less than 1 to denote unlimited. Default is unlimited.
    maxSessions: 2,

    // protractor will save the test output in json format at this path.
    // The path is relative to the location of this config.
    resultJsonOutputFile: null,

    framework: 'jasmine2',

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 100000,
        realtimeFailure: true,
        showTiming: true,
        includeStackTrace: true,
        isVerbose: true,
        onComplete: null
    },

    onPrepare: function () {
        //browser.driver.manage().window().maximize();
        global.dvr = browser.driver; //variable to call selenium directly
        global.isAngularSite = function (flag) {
            browser.ignoreSynchronization = !flag; //This setup is to configure when testing non-angular pages
        };
        browser.manage().timeouts().implicitlyWait(10000);
        browser.getCapabilities().then(function (cap) {
            browserName = cap.caps_.browserName;
        });

    }

};

这就是我在测试中尝试做的事情(我知道这不是一个很好的测试,我只是想测试 Appium 是否适用于我的 Angular 应用程序。):

it('User should see module 1s elements on the web page', function () {
   browser.sleep(6000); 
   browser.driver.findElement(by.css('.play__video'));
});

但是当我运行我的测试时,我不断收到 android 的这个错误:

编辑:我可以看到网页正在打开。

堆栈: 错误:失败:{"message":"[$injector:modulerr] 无法实例化模块 p,原因是:\n错误:[$injector:nomod] 模块 'p' 是 无法使用!您拼错了模块名称或忘记加载 它。如果注册一个模块,请确保您指定依赖项 作为第二个 参数。\nhttp://errors.angularjs.org/1.3.14/$injector/nomod?p0=p\n 在 http://WEBAPPLICATION.com/assets/javascripts/global.js:107:21272\n 在 http://WEBAPPLICATIONs.com/assets/javascripts/global.js:107:29604\n 在 t (http://WEBAPPLICATION.com/assets/javascripts/global.js:107:29176)\n

我也试过这种情况:

it('User should see module 1 s video start on the web page', function () {
    browser.wait(EC.visibilityOf(basePage.videoButtonModule1), 10000);
    basePage.videoButtonModule1.click();
    expect(basePage.videoContainerModule1.isDisplayed()).toBeTruthy();
});

但为此我收到上述错误以及此消息:

消息: 失败:等待量角器与页面同步时出错:“[ng:test] 找不到元素参数的注入器 getTestability\nhttp://errors.angularjs.org/1.3.14/ng/test"

我做错了什么???请帮忙pppp!!

编辑 2: 分享我在使用 iOS 时遇到的错误

新的登陆页面模块验证 --> 用户应该看到模块 1 s 网页上的视频开始消息: 失败:在 WEBAPP.com/ 页面上找不到 Angular:angular 从未提供 resumeBootstrap 堆栈: 错误:失败:在 WEBAPP.com/ 页面上找不到 Angular:角度 从未提供 resumeBootstrap 在 /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:102:16 在 [object Object].promise.ControlFlow.runInFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20) 在 [object Object].promise.Callback_.goog.defineClass.notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25) 在 [object Object].promise.Promise.notify_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)

【问题讨论】:

    标签: angularjs node.js protractor appium saucelabs


    【解决方案1】:

    我终于能够让它在我的测试中发挥作用,唯一能在 SAUCELABS 上发挥魔力的组合是

    multiCapabilities: [
            {
                platformName: 'iOS',
                platformVersion: '7.1',
                browserName: '',
                app: 'safari',
                deviceName: 'iPhone Simulator',
                'appium-version': "1.4.0",
                username: '<USERNAME>',
                accessKey: '<KEY>'
    
            }
            ,
            {
                platformName: 'Android',
                platformVersion: '4.4',
                browserName: 'Browser',
                deviceName: 'Android Emulator',
                'appium-version': "1.4.0",
                username: '<USERNAME>',
                accessKey: '<KEY>'
            }
    
    
            ], 
    

    其他组合而不是这些将不起作用,至少对于我的应用程序而言。

    我已对 Protractor 团队的原始问题发表评论,希望他们能回答。

    https://github.com/angular/protractor/issues/2247

    【讨论】:

      猜你喜欢
      • 2015-07-26
      • 2015-10-15
      • 2015-09-28
      • 1970-01-01
      • 2021-09-12
      • 2017-06-30
      • 2019-03-28
      • 2015-01-24
      • 2015-11-10
      相关资源
      最近更新 更多