How to find the coordinates of the buttons on a canvas, and click on them after using Java and Selenium?

前端 未结 2 1148
無奈伤痛
無奈伤痛 2020-12-04 03:37

I have an online calculator that i want to automate some operations for, like subtraction, division, etc. but the thing is that there are no elements since it is a canvas ap

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 03:58

    I think you are facing difficulty to find the coordinates of the element. To find them easily will have some plugins for each browser. For chrome, you can use Page Ruler and for Firefox, you can use MeasureIt. By using these tools you can get the coordinates of the particular element. After that, you can easily click on those elements. Watch the following video for how to use MeasureIt in firefox (follow from 11:45 minutes).

    Finding the coordinates of particular Element using Firefox MeasureIt plugin

    And your other concern is how to find the coordinates of the size of the screen changes? normally will have some standard screen sizes for each monitor or laptop. So first, get the size of the screen using selenium and then you can use if the condition for each screen size. Means, if the size is something like 800*1200 then use these coordinates else use some other coordinates for each screen size.

提交回复
热议问题