使用量角器 + Appium + SauceLabs [英] Using Protractor + Appium + SauceLabs

查看:24
本文介绍了使用量角器 + Appium + SauceLabs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试针对移动端自动化我的量角器测试.我已经阅读了网络上的大部分博客,我找到了这个是 Appium with Saucelas 的官方"博客:https://docs.saucelabs.com/tutorials/appium/#mobile-web-申请我按照那里的说明,将我的 config.js 文件配置为这个

var testName = '测试';//在此处更改项目名称以便在 BrowserStack 中识别出口.config = {//正在运行的 selenium 服务器的地址.seleniumAddress: 'http://bmsok​​o:[redacted]@ondemand.saucelabs.com:80/wd/hub',//传递给 webdriver 实例的能力.多能力:[{名称:测试名称,'appium-version': '1.4.0','浏览器名称': '安卓','deviceName': 'Android 模拟器','设备方向':'肖像','平台': 'Linux','版本':'5.1',用户名:'bmsok​​o',accessKey: '[已编辑]'}],//规范模式是相对于当前直接工作的//量角器被调用.套房:{手机:'./././specs/mobile.js'},//要运行的最大浏览器会话总数.测试在排队//如果浏览器会话数受此参数限制,则排序.//使用小于 1 的数字表示无限制.默认为无限制.最大会话数:2,//量角器会将测试输出以json格式保存在此路径.//路径是相对于这个配置的位置.resultJsonOutputFile: null,框架:'茉莉花2',//传递给 Jasmine-node 的选项.茉莉花节点选项:{显示颜色:真实,默认超时间隔:100000,realtimeFailure: 真,显示时间:真实,包括堆栈跟踪:真,isVerbose:真实,onComplete:空},onPrepare: 函数 () {//browser.driver.manage().window().maximize();global.dvr = browser.driver;//直接调用selenium的变量global.isAngularSite = 函数(标志){browser.ignoreSynchronization = !flag;//这个设置是在测试非角度页面时配置};browser.manage().timeouts().implicitlyWait(10000);browser.getCapabilities().then(function (cap) {浏览器名称 = cap.caps_.browserName;});}};

这是我在测试中尝试做的事情(我知道这不是一个很好的测试,我只是想测试 Appium 是否与我的 Angular 应用程序配合使用.):

<块引用>

it('用户应该在网页上看到模块 1s 的元素', function () {浏览器睡眠(6000);browser.driver.findElement(by.css('.play__video'));});

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

EDIT:我可以看到网页正在打开.

<块引用>

堆栈:错误:失败:{"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('用户应该在网页上看到模块 1 的视频开始', function () {browser.wait(EC.visibilityOf(basePage.videoButtonModule1), 10000);basePage.videoButtonModule1.click();期望(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: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)

解决方案

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

multiCapabilities: [{平台名称:'iOS',平台版本:'7.1',浏览器名称:'',应用程序:野生动物园",deviceName: 'iPhone 模拟器','appium-version': "1.4.0",用户名:'<用户名>',accessKey: ''},{平台名称:'Android',平台版本:'4.4',浏览器名称:'浏览器',deviceName: 'Android 模拟器','appium-version': "1.4.0",用户名:'<用户名>',accessKey: ''}],

其他组合而不是这些组合不起作用,至少对我的应用而言是这样.

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

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

I've been dealing to try to automate against Mobile my protractor tests. I've read most of the blogs around the web, I reached this one which is the "official" for Appium with Saucelabs: https://docs.saucelabs.com/tutorials/appium/#mobile-web-application I followed instructions there, and configured my config.js file as this

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;
        });

    }

};

and here's what I'm trying to do in my test (I know its not a very good test, I just wanted to test Appium works with my angular app.):

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

But when I run my tests, I keep getting this error for android:

EDIT: I can see that the web page is being opened.

Stack: Error: Failed: {"message":"[$injector:modulerr] Failed to instantiate module p due to:\nError: [$injector:nomod] Module 'p' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.\nhttp://errors.angularjs.org/1.3.14/$injector/nomod?p0=p\n at http://WEBAPPLICATION.com/assets/javascripts/global.js:107:21272\n at http://WEBAPPLICATIONs.com/assets/javascripts/global.js:107:29604\n at t (http://WEBAPPLICATION.com/assets/javascripts/global.js:107:29176)\n

I've also tried this scenario:

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();
});

but for this I get the above error plus this message:

Message: Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.3.14/ng/test"

What am I doing wrong???? Please helppppp!!

EDIT 2: Sharing the error that I'm getting with iOS

New Landing page module verification --> User should see module 1 s video start on the web page Message: Failed: Angular could not be found on the page WEBAPP.com/ : angular never provided resumeBootstrap Stack: Error: Failed: Angular could not be found on the page WEBAPP.com/ : angular never provided resumeBootstrap at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:102:16 at [object Object].promise.ControlFlow.runInFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20) at [object Object].promise.Callback_.goog.defineClass.notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25) at [object Object].promise.Promise.notify_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)

解决方案

I was able to finally make it work for my tests, the only combination that does the magic ONLY ON SAUCELABS is

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>'
        }


        ], 

Other combination rather than these won't work, at least for my app.

I have placed a comment on my original issue for Protractor team hoping they'll answer it.

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

这篇关于使用量角器 + Appium + SauceLabs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆