My current dilemma involves looping through each point of a line chart in HighCharts with Selenium. The issue is that the loop goes from right to left, but I prefer it to go from left to right (I'm particular about this). To achieve this, I need to start the loop from last-of-type to nth-of-type(1), rather than the other way around.
Below is the code snippet that currently loops from right to left:
public static boolean isLastPoint(int series,WebDriver driver){
if(series > 1){
WebElement last = driver.findElement(By.cssSelector("g.highcharts-series-group > g:nth-of-type(2) > path:last-of-type"));
WebElement current = driver.findElement(By.cssSelector("g.highcharts-series-group > g:nth-of-type(2) > path:nth-of-type(" + (series) + ")"));
return last.equals(current);
}
else return false;
}
public static void overview(WebDriver driver, boolean active) {
if(active){
wait(driver,By.id("highcharts-0"));
WebElement chart0 = driver.findElement(By.id("highcharts-0"));
LineChart lc0 = new LineChart(driver,chart0);
int series = 1;
while(!isLastPoint(series-1,driver)){
lc0.hoverOverLineChart1(series, "");
series++;
}
}else return;
}