How to Get Text inside a Canvas using Webdriver or Protractor
https://stackoverflow.com/questions/43609429/how-to-get-text-inside-a-canvas-using-webdriver-or-protractor
https://sqa.stackexchange.com/questions/3253/how-to-automate-the-action-on-a-canvas-object-when-the-canvas-element-has-no-na
To work inside a canvas you can use the Kantu web automation software or Sikuli. Both solutions are based on screenshots, image comparison and OCR, and can get the text inside the canvas.
You mark the data that you want to extract ("scrape") by drawing pink frames around it. Kantu then retrieves the data by using OCR. With Sikuli, you would need to find out the coordinates first.
Or, as JeffC suggested, use your current software to take a screenshot, and then OCR it. For OCR, there is the well-known Tesseract lib or use an online service like the free ocr.space.
The basics are that you can't with Selenium. the CANVAS
tag is like an applet in the page. It doesn't actually contain any HTML. There are a few options:
If you have access to the devs, you can have them expose an API for you so that you can access text, etc. using Javascript from your Selenium script. If it's part of some library, etc. the library itself may provide an API that you can use. This is the most reliable option.
For executing actions, you can use coordinates. You can base all click, etc. actions off coordinates but this is highly dependent on the browser rendering, screen resolution, etc. This will not help you get text out of the
CANVAS
though.For the text, you really don't have any options to get the text directly. You could take screenshots and verify the text after the run is complete but that's about your best option. If you wanted to get really fancy, depending on the text, etc. you may be able to find an OCR library that will be able to extract the text from the screenshot that you took.
Canvas does not separate the graphics it drew included text. You need OCR. You may use a tool to cut the canvas image to clipboard and invoke a program to paste the image to preprocess, and perform OCR. Image preprocessing will extract the region of interest which is the text to improve OCR accuracy.
How to Get Text inside a Canvas using Webdriver or Protractor的更多相关文章
- jsp报错问题之“使用jstl的c标签choose报错Illegal text inside "c:choose" tag问题”
一.报错 [bessky_it][ERROR][2022-03-25 17:19:07] | PLATFORM | ):[c]鍜孾/com.bessky.pss.portal/purchase/sam ...
- Html5 Canvas Text
html5 canvas中支持对text文本进行渲染;直接的理解就是把text绘制在画布上,并像图形一样处理它(可以加shadow.gradient.pattern.color fill等等):既然它 ...
- 在canvas上面拖拽对象。
原文:https://html5.litten.com/how-to-drag-and-drop-on-an-html5-canvas/ 下面作者的原始的版本会抖动一下(鼠标刚点下去的时候,位置会发生 ...
- H5 canvas的 width、height 与style中宽高的区别
Canvas 的width height属性 1.当使用width height属性时,显示正常不会被拉伸:如下 <canvas id="mycanvas" width=&q ...
- HTML5移动开发学习笔记之Canvas基础
1.第一个Canvas程序 看的是HTML5移动开发即学即用这本书,首先学习Canvas基础,废话不多说,直接看第一个例子. 效果图为: 代码如下: <!DOCTYPE html> < ...
- canvas调用scale或者drawImage图片操作后,锯齿感很明显的解决
<script type="text/javascript"> //解决canvas画画图片 var mengvalue = -1; var phoneWidth = ...
- 用Canvas实现动画效果
1.清除Canvas的内容 clearRect(x,y,width,height)函数用于清除图像中指定矩形区域的内容 <!doctype html> <html> <h ...
- Canvas制作天气预报走势图
要实现的效果如下图: HTML代码如下: ;;;;;;;;;;; }
- html5、canvas绘制本地时钟
效果图: 代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
随机推荐
- MYSQL: set names utf8是什么意思?
set names utf8 是用于设置编码,可以再在建数据库的时候设置,也可以在创建表的时候设置,或只是对部分字段进行设置,而且在设置编码的时候,这些地方最好是一致的,这样能最大程度上避免数据记录出 ...
- Python 全栈开发八 文件处理
一.基本流程 打开文件得到文件句柄 将文件句柄赋值给一个变量 通过文件句柄对文件进行操作 关闭文件 二.基本操作 1.文件句柄 f = open("a.txt",encoding= ...
- 15个Node.js项目列表
前言: Node.js 是一个基于Chrome JavaScript 运行时建立的一个平台,是一个事件驱动I/O服务端JavaScript环境,基于Google的V8引擎,V8引擎执行Javascri ...
- 合理利用配置不同的机器资源做redis cluster的server
Redis cluster可以使用不同配置的机器学习因为我们可以手动调整不同的机器所承担的slot的个数,这样内存小CPU相对少的机器应该承担更少的slots
- Linux配置SSH免登录
[root@Linux01 ~]# ssh-keygen #生成公私钥 [root@Linux01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub hadoopuser@Ha ...
- uml的几种关系总结
UML类图几种关系的总结 在UML类图中,常见的有以下几种关系:泛化(Generalization), 实现(Realization),关联(Association),聚合(Aggregati ...
- React项目中使用Mobx状态管理(一)
1.安装 $ yarn add mobx mobx-react 2.新建store/index.js,存放数据(以下思路仅限于父子组件的简单应用) 注意:这里暂时没使用装饰器@observable,装 ...
- beego 初体验 - orm
goland Terminal运行命令: go get github.com/astaxie/beego/orm 安装go mysql驱动: go get github.com/go-sql-driv ...
- jquer文字闪烁简单实现
arguments.callee <script type="text/javascript"> (function () { $(".usesend&quo ...
- Python - 3. Input and Output
from:http://interactivepython.org/courselib/static/pythonds/Introduction/InputandOutput.html Input a ...