Interacting with a Canvas with Selenium

后端 未结 2 1807
无人共我
无人共我 2021-01-05 03:46

I\'ve done a bit of reading on this, but haven\'t been able to find something specific. I have a canvas object that I need to interact with, with Selenium. However as we all

2条回答
  •  时光说笑
    2021-01-05 04:05

    try this ,it worked for me.This will draw a circle on the 'canvas' id.

    public function testDraw() {
            try {
                $this->execute(array('script' => "  var c = document.getElementById('canvas');
                 var ctx = c.getContext('2d');
                ctx.beginPath();
                   ctx.arc(100, 75, 50, 0, 2 * Math.PI);
                    ctx.stroke();",
                    'args' => array()));
    
                echo 'done';
                sleep(10);
            } catch (Exception $ex) {
                echo 'not done';
            }
    

提交回复
热议问题