【问题标题】:Where to start with this protractor task?这个量角器任务从哪里开始?
【发布时间】:2017-04-05 01:33:07
【问题描述】:

我有一项任务要准备,但我是量角器领域的新手。你可以帮帮我吗? 唯一的信息是“从自动化测试人员的位置您将如何处理”

'use strict';
var constants = require('../../constants/other/constants.js');
var ContextMenuPage = require('../../page objects/base page/context_menu_page.js');
var functions = require('../../helper/functions.js');
var ClientScenariosPage = require('../../page objects/impairment analysis/client/scenarios_page.js');
var IADashboardPage = require('../../page objects/impairment analysis/ia_dashboard_page.js');
var BasePage = require('../../page objects/base page/base_page_object.js');
describe('Impairment analysis - dashboard', function () {
    var individualAssessment = new IndividualAssessment();
    var iaDashboardPage = new IADashboardPage();
    var basePage = new BasePage();
    var footer = basePage.getFooter();
    var clientScenariosPage = new ClientScenariosPage();

    it('should log in', function () {
        browser.ignoreSynchronization = true;
        helper.login();
    });

    it('should change calcset', function () {
        browser.sleep(4000)
        var CalcSet = element(by.xpath('//div[@class="calcset"]/strong[@class="ng-binding"]'));
        CalcSet.click();
        var input = element(by.xpath("//input[@class='k-input ng-pristine ng-untouched ng-valid ng-scope ng-empty']"));
        input.clear();
        input.sendKeys('16080902');
        input.sendKeys(protractor.Key.ENTER);
        footer.getCalcsetDialog().clickSetButton();
    });

    it('should go to individual assessment', function () {
        individualAssessment.getBasePage().clickContextMenu();
        contextMenu.clickImpairmentAnalysisTile();
        iaDashboardPage.clickIndividualAssesmentTile();
    });

    it('should go to scenarios screen and assign collaterals', function () {

        browser.sleep(5000);

        for (var id of ["127-1", "129-1", "128", "125-1"]) {
            var client = element(by.xpath("//div[@id='DashboardD1LISTTODO']/div[@class='k-grid-content k-auto-scrollable']/table[@class='k-selectable']/tbody/tr[@id='" + id + "']/td[@class='row-click'][2]/span[@class='link']"));
            client.click();
            clientScenariosPage.getBasePage().getCarousel().clickIndicatorByName('Scenarios');
            browser.sleep(2000);
            var coll_button = element(by.xpath("//trtd[5]/a[@title='Show collateral allocations']"));
            coll_button.click();
            check_and_click();
            browser.sleep(3000);
            var back = element(by.xpath("//div[@id='listClientCollModal']/div[@class='modal-dialog']/div[@class='modal-content']/div[@class='modal-body']/button[@class='close']"));
            back.click();
            individualAssessment.getBasePage().clickContextMenu();
            contextMenu.clickImpairmentAnalysisTile();
            iaDashboardPage.clickIndividualAssesmentTile();
            browser.sleep(5000);
        });
    });

    it('should log out', function () {
        helper.logout();
    });
});

这是一个棘手的问题吗?我应该询问更多细节,例如它将测试的页面,还是只准备一些方法? 我期待着您的回音, 托梅克

【问题讨论】:

  • 先尝试一下,但如果您遇到困难,请回来询问具体问题。
  • @Hida 我唯一能用它做的事情就是我可以运行它。运行后我得到:[16:46:22] E/launcher - Error: Error: Cannot find module '../../constants/other constants.js' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (C:\Pro\spec.js:2:17) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12)
  • 量角器无法找到constants.js 文件。确保文件路径正确。你可以检查使用require.resolve(path/to/module)
  • 您能否详细说明问题?他们要你分析代码?
  • @Martin Blaustein - 没错,我必须分析代码并提出建议。如果我错了,请纠正我,但应该添加一些“那么”。我还阅读了有关添加黄瓜和 Page Obj 的信息。你怎么看

标签: javascript angularjs automation protractor automated-tests


【解决方案1】:

所以你应该知道 jasmine 的工作原理和页面对象模式 (http://martinfowler.com/bliki/PageObject.html)。

这样就不需要知道量角器来分析测试的作用,只需尝试想象每一个动作,比如找到某物 -> 点击它 -> 断言它

您也可以说他们没有测试角度页面 (browser.ignoreSynchronization = true;)

从不声明辅助对象。

我想关于它还有很多话要说。

【讨论】:

  • 谢谢,我去看看。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-30
  • 2015-06-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多