5

There is a similar question out there (an older one in Python) but this one has to do with JS. Testing using Selenium in a NodeJS, Mocha environment. What I'd like to do is click on a Bootstrap dropdown and check the HTML to look for changes. I've tried the following:

test.it('should click on all header links',
function() {
    var elem = driver.findElement(By.id('Profile'));
    console.log(elem.getAttribute('innerHTML'));
    console.log(elem.getInnerHtml());
});

Both calls return the same thing.

{ then: [Function: then],
  cancel: [Function: cancel],
  isPending: [Function: isPending] }

I plan to feed the HTML into cheerio so i can check for structure changes. Appreciate any help on this.

2 Answers 2

6

I was able to retrieve the HTML as a string by doing the following.

driver.findElement(By.id('Profile')).getAttribute("innerHTML").then(function(profile) {
    console.log(profile);
});
Sign up to request clarification or add additional context in comments.

Comments

0

I got the inner HTML with:

  element.getAttribute('innerHTML').then(function (html) {          
                console.log(html)
            })

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.