Reputation: 385
I wish to get the "Testing 2" text inside a class called "inner" as shown below.
<div _ngcontent-c6="" class="inner">
<h1 _ngcontent-c6=""> Testing 2
</h1>
</div>
I tried "return element(by.css('.inner')).element(by.css("h1")).getText();" and "return element(by.className('inner')).element(by.css("h1")).getText();" but both codes are not working.
When running the said codes I got the same error saying "Failed: No element found using locator: By(css selector, h1)"
How can I get the value of h1 inside a div with a class name?
Upvotes: 1
Views: 671
Reputation: 13712
Try wait for a while.
var EC = protractor.ExpectedConditions;
var target = element(by.css('div.inner > h1'));
browser.wait(EC.presenceOf(target), 15*1000);
target.getText().then(function(txt){
console.log('H1: ' + txt);
});
Upvotes: -1