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

getInnerHtml() is not a function but getText() works #4041

Closed
philjones88 opened this issue Jan 31, 2017 · 5 comments
Closed

getInnerHtml() is not a function but getText() works #4041

philjones88 opened this issue Jan 31, 2017 · 5 comments

Comments

@philjones88
Copy link

philjones88 commented Jan 31, 2017

Bug report

  • Node Version: 7.4.0
  • Protractor Version: 5.0.0
  • Angular Version: 2.4.4
  • Browser(s): chrome
  • Operating System and Version OSX Sierra 10.12.2
  • Your protractor configuration file
  • A relevant example test
let error = 'An error occurred loading that page. Please try again.';
let securityError = 'Request rejected. You do not have permission for the resource requested.';

let pageContainer = this.master.pageContainer();

pageContainer.isPresent().then((present) => {
    console.log('expectNoErrorPage => present', present);
    console.log('expectNoErrorPage', pageContainer);

    if (!present) {
        return;
    }

    // Works
    pageContainer.getText().then((text) => console.log('expectNoErrorPage text', text));

    // Boom
    pageContainer.getInnerHtml().then((html) => console.log('expectNoErrorPage html', html));

    // Original code that blows up below..
    // expect(pageContainer.getInnerHtml()).not.toContain(error);
    // expect(pageContainer.getInnerHtml()).not.toContain(securityError);
});
  • Output from running the test
expectNoErrorPage => present true
expectNoErrorPage ElementFinder {
... lots of stuff
}
....
Failed: pageContainer.getInnerHtml is not a function
  • Steps to reproduce the bug

use .getInnerHtml() or .getOuterHtml()

  • The URL you are running your tests against (if relevant)
@cnishina
Copy link
Member

Please read the changelog, this was covered as a breaking change as well as a work around.

@philjones88
Copy link
Author

@cnishina shame you can't do something to the typings and TS to highlight issues like that

@decoded4620
Copy link

decoded4620 commented May 12, 2017

What was the an actual reason those methods were removed from the Selenium WebDriver without replacements? Also curious, how can we update the public Any Angular 4 / protractor documentation to reflect the change. The ElementFinder API still states that this should be a working function.

@jmcollin78
Copy link

So the changelog says, we have to replace all:
let i = element(locator).getInnerHtml();
by:
let i = browser.executeScript("return arguments[0].innerHTML;", element(locator));
I really really prefer the first form which was natural and fully comprehensive for human being. Is it possible to revert that removal ?

@lezhumain
Copy link

Coming back from the future it's seems that it's now possible to do:

let i = browser.element(locator).getAttribute('innerHTML')

(See https://stackoverflow.com/a/27571812/3482730)

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

5 participants