Quality Testing

Quality is delighting customers

WebElement.getText() does not work in Selenium WebDriver

<ul id="name" class="abc">
        <li class="def">
             <a class="ghi">
                <i style="background-color: transparent;">Welcome {{username}} </i>
             </a>
        </li>
</ul>

I am using Chrome browser. The below code returns me empty string.

driver.findElement(By.xpath("//ul[@id='name']/li/a/i")).getText();

Views: 175

Reply to This

Replies to This Discussion

try driver.findElement(By.xpath("//ul[@id='name']/li/a/i")).getAttribute("textContent")

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2020   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service