use of org.jenkinsci.test.acceptance.po.PageObject in project code-coverage-api-plugin by jenkinsci.
the class ChartUtil method getChartDataById.
/**
* Returns a chart's data by its id.
*
* @param pageObject
* which contains chart
* @param elementId
* of chart
*
* @return data as json
*/
public static String getChartDataById(final PageObject pageObject, final String elementId) {
if (isChartDisplayedByElementId(pageObject, elementId)) {
Object result = pageObject.executeScript(String.format("delete(window.Array.prototype.toJSON) %n" + "return JSON.stringify(echarts.getInstanceByDom(document.getElementById(\"%s\")).getOption())", elementId));
ScriptResult scriptResult = new ScriptResult(result);
return scriptResult.getJavaScriptResult().toString();
}
return null;
}
use of org.jenkinsci.test.acceptance.po.PageObject 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