javascript - Test a Chart.js canvas with Protractor - Stack Overflow

I'm fairly new to protractor so sorry if this is a stupid question. I'm looking into testing

I'm fairly new to protractor so sorry if this is a stupid question. I'm looking into testing an application and need test the values inside a Chart.js graph.

Has anyone got any ideas on how to get my protractor program to look inside the canvas.

This is the canvas output in HTML.

<canvas id="test" 
        class="chart chart-line ng-isolate-scope" 
        data="test.data" 
        labels="test.labels" 
        series="test.series" 
        legend="true" 
        options="test.options" 
        colours="test.colours" 
        width="1816" 
        height="800" 
        style="width: 908px; 
        height: 400px;">
</canvas>

Thanks in advance.

I'm fairly new to protractor so sorry if this is a stupid question. I'm looking into testing an application and need test the values inside a Chart.js graph.

Has anyone got any ideas on how to get my protractor program to look inside the canvas.

This is the canvas output in HTML.

<canvas id="test" 
        class="chart chart-line ng-isolate-scope" 
        data="test.data" 
        labels="test.labels" 
        series="test.series" 
        legend="true" 
        options="test.options" 
        colours="test.colours" 
        width="1816" 
        height="800" 
        style="width: 908px; 
        height: 400px;">
</canvas>

Thanks in advance.

Share Improve this question asked Jan 13, 2016 at 9:47 Evan BurbidgeEvan Burbidge 8679 silver badges17 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

I think you may get the underlying chart data, by evaluating in the canvas's context. Example:

var canvas = element(by.css("canvas#test[data]"));
canvas.evaluate("test.data").then(function (data) {
    console.log(data);
});

Protractor can get attributes of the canvas, but it can't access object created within it. But it depends what you're looking to do. Strategies for canvas testing might include image diffs, and string diffs, and often make use of browser.actions for manipulating them.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744609208a4583661.html

相关推荐

  • javascript - Test a Chart.js canvas with Protractor - Stack Overflow

    I'm fairly new to protractor so sorry if this is a stupid question. I'm looking into testing

    2天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>