use of com.gargoylesoftware.htmlunit.ScriptResult in project code-coverage-api-plugin by jenkinsci.
the class ChartUtil method getDataOfOnlyChartOnPageWithGivenToolAttribute.
/**
* Returns data of only chart with given tool attribute value on page.
*
* @param pageObject
* which contains only one chart with given tool attribute value
* @param toolAttribute
* value in div tag of chart
*
* @return data as json
*/
public static String getDataOfOnlyChartOnPageWithGivenToolAttribute(final PageObject pageObject, final String toolAttribute) {
if (isChartDisplayedByDivToolAttribute(pageObject, toolAttribute)) {
for (int i = 0; i < MAX_ATTEMPTS; i++) {
Object result = pageObject.executeScript(String.format("delete(window.Array.prototype.toJSON) %n" + "return JSON.stringify(echarts.getInstanceByDom(document.querySelector(\"div [tool='%s']\")).getOption())", toolAttribute));
Object scriptResult = new ScriptResult(result).getJavaScriptResult();
if (scriptResult != null) {
return scriptResult.toString();
}
pageObject.elasticSleep(1000);
}
}
throw new java.util.NoSuchElementException("Found no trend chart with ID '%s''" + toolAttribute);
}
Aggregations