The "Objects + non angular" page - how to join them?

I am writing some protractor tests for our application. There is one place where the <angular page is the iframe on the angular page.

Problem: I cannot match the fields from the <angular page in the page object object and use them at the right time in my test specs.

Notes:

  • I tried to write Object Object as an object (var DamagePage: {}) and as a function (var DamagePage = function () {}) too. Both work poorly in this situation.
  • Calling fields from a non-w500> page in the specifications works, obviously, fine, but I want to have it in Page Object to properly organize the project.
  • I set browser.driver.ignoreSynchronization = true;

Here is my spec>

'use strict';

var DamagePage = require('../../pages/case/CaseDamagePage.po.js');

describe('Damage selection - ', function() {

  var damagePage = new DamagePage();

  it('Switch to iFrame',function(){
      browser.driver.switchTo().frame('padIframe');
  });

  it('Open a zone', function() {
      browser.driver.findElement(by.id('30_0_79')).click();
      browser.sleep(2000);
  });

  it('Select a part', function () {
      browser.driver.findElement(by.id('32_0_201')).click();
      browser.sleep(3000);
  });

  it('Put I on it with 5 WU', function() {
      // Click I
      damagePage.leftMenuButtons.I.button.click();
  });

And here is my PageObject (actually as a function)>

'use strict';

var CaseInterface = require('./CaseInterface.js');

var DamagePage = function() {

  // LEFT-SITE MENU BUTTONS
  this.leftMenuButtons = {
      I: {
          button: browser.driver.findElement(by.id('operation-button-I'))
      },
      E: {
          button: element(by.id('operation-button-E')),
          mutation: element(by.id('operation-button-mutation-E'))
      }
  };
};

module.exports = DamagePage;

, " 5 WU". :

C:\Users\\AppData\Roaming\\node_modules\\node_modules\ WebDriver\Lib\\error.js: 108  var template = new (this.message);                  ^ NoSuchElementError: : : { "method": "id", "selector": "operation-button-I" }   ( : chrome = 47.0.2526.106)   ( : chromedriver = 2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1), = Windows NT 6.1 SP1 x86_64) (: ) - : 22 , , : http://seleniumhq.org/exceptions/no_such_element.html

, "browser.driver.findElement" Object Object. "", , " 5 WU". :

: Protractor : "angular "

+4
1

- , Object Object - Protractor, , . beforeEach():

describe('Damage selection - ', function() {
    var damagePage;

    beforeEach(function () {
       damagePage = new DamagePage();
    });

    // ...
});

it():

it('Put I on it with 5 WU', function() {
    var damagePage = new DamagePage();

    // Click I
    damagePage.leftMenuButtons.I.button.click();
});
+2

Source: https://habr.com/ru/post/1625528/


All Articles