摘要
HolliView产品页面采用Canvas绘制,Canvas是一个图形容器,为实现画面上元素特性的自动化组态及测试,首先需定位到画布上需要操作的元素,而Selenium的基本定位方式只能定位到该画布上,无法定位到画布上的具体元素,因此需要使用Selenium的JS注入的方式,通过插入JS脚本的方式获取所要操作的元素坐标,再使用ActionChains对应的鼠标动作去执行对应的操作。目前画面元素动态交互特性自动化测试已实现,并已应用到HolliView项目中。
HolliView product page is drawn by Canvas,Canvas is a graphic container.In order to realize the automatic configuration and test of the element characteristics on the screen,it is necessary to locate the elements that need to be operated on the Canvas first.However,selenium can only locate the specific elements on the Canvas.Therefore,we need to use the JS injection method of selenium and insert JS script to obtain the elements to be operated coordinate,and then use the mouse action corresponding to ActionChains to perform the corresponding operation.At present,the automatic test of dynamic characteristics and Interactive features of Canvas elements has been realized,and has been applied to HolliView project.
作者
王新月
王奚
WANG Xinyue;WANG Xi(Ningbo Hollysys Information Security Institute Co.,Ltd.,Xi'an 710075;Beijing Hollysys Intelligent Technology Co.,Ltd.,Xi'an 710075)
出处
《现代计算机》
2021年第21期137-141,共5页
Modern Computer