Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getRect() is not available #5319

Open
Dyadko opened this issue Sep 19, 2019 · 4 comments
Open

getRect() is not available #5319

Dyadko opened this issue Sep 19, 2019 · 4 comments

Comments

@Dyadko
Copy link

Dyadko commented Sep 19, 2019

Bug report

As per https://github.com/angular/protractor/blob/master/CHANGELOG.md#600 , getSize() and getLocation() in WebElement are substituted by getRect(). But during runtime the method is not found.

  • Node Version: 11.8.0
  • Protractor Version: 6.0.0
  • Angular Version: --
  • Browser(s): Chrome 76.0.3809.68
  • Operating System and Version Windows 10Pro
  • Your protractor configuration file
  • A relevant example test
77     const oooo = await $('#mat-dialog-title-1');
78     const osize = await oooo.getRect();
  • Output from running the test
       TypeError: oooo.getRect is not a function
           at World.When (C:\GitHub\DigitalAutomationTesting\step_definitions\search\searchBarSteps.js:78:28)

Despite the release notes the getSize() method is available but fails inside itself.

77    const oooo = await $('#mat-dialog-title-1');
78    const oSize = await oooo.getSize();

Output:

       TypeError: Cannot read property 'apply' of undefined
           at actionFn (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:95:44)
           at Array.map (<anonymous>)
           at actionResults.getWebElements.then (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:461:44)
           at processTicksAndRejections (internal/process/next_tick.js:81:5)Error
           at ElementArrayFinder.applyAction_ (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:459:29)
           at ElementArrayFinder.(anonymous function).args [as getSize] (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:97:29)
           at ElementFinder.(anonymous function).args [as getSize] (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:818:22)
           at World.When (C:\GitHub\DigitalAutomationTesting\step_definitions\search\searchBarSteps.js:78:28)

In other words, there is no ability to get element size and coordinates with protractor 6.0.0.

@mynameishsandeep
Copy link

Facing the same issue, when upgraded to protractor version: 6.0.0 & selenium-webdriver: 4.0.0-alpha.5 with node version: 12.13.0

Replaced the elementFinder.getLocation() to elementFinder.getRect(), then getting following error,

Error in scrolling the element into view. TypeError: Cannot read property 'apply' of undefined
at actionFn (/Users//node_modules/protractor/built/element.js:95:44)
at Array.map ()
at actionResults.getWebElements.then (/Users/testproject/node_modules/protractor/built/element.js:461:44)
at process.tickCallback (internal/process/next_tick.js:68:7)Error
at ElementArrayFinder.applyAction
(/Users/testproject/node_modules/protractor/built/element.js:459:29)
at ElementArrayFinder.(anonymous function).args [as getLocation] (/Users/testproject/node_modules/protractor/built/element.js:97:29)
at ElementFinder.(anonymous function).args [as getLocation] (/Users/testproject/node_modules/protractor/built/element.js:818:22)
at _basepage2.default.getUniversalHeader_Height.then.height (/Users/testproject/dist/components/component.js:62:29)
at tryCallOne (/Users/testproject/node_modules/promise/lib/core.js:37:12)
at /Users/testproject/node_modules/promise/lib/core.js:123:15
at flush (/Users/testproject/node_modules/asap/raw.js:50:29)
at process._tickCallback (internal/process/next_tick.js:61:11)

@mynameishsandeep
Copy link

mynameishsandeep commented Oct 23, 2019

Bug report

As per https://github.com/angular/protractor/blob/master/CHANGELOG.md#600 , getSize() and getLocation() in WebElement are substituted by getRect(). But during runtime the method is not found.

  • Node Version: 11.8.0
  • Protractor Version: 6.0.0
  • Angular Version: --
  • Browser(s): Chrome 76.0.3809.68
  • Operating System and Version Windows 10Pro
  • Your protractor configuration file
  • A relevant example test
77     const oooo = await $('#mat-dialog-title-1');
78     const osize = await oooo.getRect();
  • Output from running the test
       TypeError: oooo.getRect is not a function
           at World.When (C:\GitHub\DigitalAutomationTesting\step_definitions\search\searchBarSteps.js:78:28)

Despite the release notes the getSize() method is available but fails inside itself.

77    const oooo = await $('#mat-dialog-title-1');
78    const oSize = await oooo.getSize();

Output:

       TypeError: Cannot read property 'apply' of undefined
           at actionFn (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:95:44)
           at Array.map (<anonymous>)
           at actionResults.getWebElements.then (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:461:44)
           at processTicksAndRejections (internal/process/next_tick.js:81:5)Error
           at ElementArrayFinder.applyAction_ (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:459:29)
           at ElementArrayFinder.(anonymous function).args [as getSize] (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:97:29)
           at ElementFinder.(anonymous function).args [as getSize] (C:\GitHub\DigitalAutomationTesting\node_modules\protractor\built\element.js:818:22)
           at World.When (C:\GitHub\DigitalAutomationTesting\step_definitions\search\searchBarSteps.js:78:28)

In other words, there is no ability to get element size and coordinates with protractor 6.0.0.

@Dyadko Dyadko Found a workaround for this issue, instead of calling .getRect() on ElementFinder of Protractor, get the webElement from elementFinder like

   return elementFinder.getWebElement().then((webElement) => {
      return  webElement.getRect();
  }).then((rect) => {
       console.log(rect.width, rect.height);
        return Promise.resolve();
  }).catch((err) => {
        return Promise.reject(err);
   });

@mynameishsandeep
Copy link

mynameishsandeep commented Oct 23, 2019

Facing the same issue, when upgraded to protractor version: 6.0.0 & selenium-webdriver: 4.0.0-alpha.5 with node version: 12.13.0

Replaced the elementFinder.getLocation() to elementFinder.getRect(), then getting following error,

Error in scrolling the element into view. TypeError: Cannot read property 'apply' of undefined
at actionFn (/Users//node_modules/protractor/built/element.js:95:44)
at Array.map ()
at actionResults.getWebElements.then (/Users/testproject/node_modules/protractor/built/element.js:461:44)
at process.tickCallback (internal/process/next_tick.js:68:7)Error
at ElementArrayFinder.applyAction
(/Users/testproject/node_modules/protractor/built/element.js:459:29)
at ElementArrayFinder.(anonymous function).args [as getLocation] (/Users/testproject/node_modules/protractor/built/element.js:97:29)
at ElementFinder.(anonymous function).args [as getLocation] (/Users/testproject/node_modules/protractor/built/element.js:818:22)
at _basepage2.default.getUniversalHeader_Height.then.height (/Users/testproject/dist/components/component.js:62:29)
at tryCallOne (/Users/testproject/node_modules/promise/lib/core.js:37:12)
at /Users/testproject/node_modules/promise/lib/core.js:123:15
at flush (/Users/testproject/node_modules/asap/raw.js:50:29)
at process._tickCallback (internal/process/next_tick.js:61:11)

Found a workaround for this issue, instead of calling .getRect() on ElementFinder of Protractor, get the webElement from elementFinder like

return elementFinder.getWebElement().then((webElement) => {
return webElement.getRect();
}).then((rect) => {
console.log(rect.width, rect.height);
return Promise.resolve();
}).catch((err) => {
return Promise.reject(err);
});

@pawelusfr
Copy link

I see this is fixed on master now. @cnishina any plans to release 6.0.1 anytime soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants