0

Please take a look at this page: https://bitly.com/2wokiu4+

While the Mouse is over this blue chart there is some text that i want to read and compare it to another value on this Page (CLICK)

Any idea how can i read this Value ?

I try to search it over the HTML

1 Answer 1

1

Code below gets all charts with not 0 height, chart clicks count for each, summarizes all and compares with clicks amount in the top right corner.

WebDriverWait wait = new WebDriverWait(driver, 20);
Actions actions = new Actions(driver);

int clicks = Integer.valueOf(wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("info-wrapper--clicks-text"))).getText());

List<WebElement> charts = wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector(".highcharts-series-group rect:not([height='0'])")));

AtomicInteger totalChartClicks = new AtomicInteger();

charts.forEach(webElement -> {
    actions.moveToElement(webElement).perform();
    int amount = Integer.valueOf(driver.findElement(By.cssSelector("div.highcharts-tooltip span:nth-of-type(2)")).getText().replace("Total Clicks ",""));
    totalChartClicks.addAndGet(amount);
});

Assert.assertEquals(totalChartClicks.get(), clicks);
Sign up to request clarification or add additional context in comments.

2 Comments

Can you explain please the charts.forEach ?
You can find explanation here

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.