Just started studying Selenium. I have a problem. Сan't get text. getText() returns empty string. getAttribute() returns null.
The getText() is used on a HTML element that looks like this: first element:
<span _ngcontent-enu-c116="" class="line-chart-tab-value ng-star-inserted"> 2 807,60 $ </span>
second element:
<span _ngcontent-enu-c116="" class="line-chart-tab-value ng-star-inserted"> 200,00 $ </span>
find by xpath:
WebElement sale = (By.xpath("//label[1]//span[@class='line-chart-tab-value ng-star-inserted']")));
System.out.println("Sale=" + sale.getText());
WebElement saleReturn= driver.findElement((By.xpath("//label[2]//span[@class='line-chart-tab-value ng-star-inserted']")));
System.out.println("Return=" + saleReturn.getText());
I would be grateful for any help.
List<WebElement> Ele = driver.findElements(By.xpath("//span[@class='line-chart-tab-value ng-star-inserted']"));
for(int i=0;i<Ele.size();i++) {
System.out.println("Sale "+Ele.get(0).getText());
System.out.println("Return "+Ele.get(1).getText());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.