我正在使用JAVA中的Selenium使基于地图的Web应用程序(使用'MapBox')自动化。
将地图作为单个图像检索,我必须在地图中找到不同区域的坐标。
为此,我找到了x&y坐标并执行了点击操作。但是我们确实有不同分辨率的机器来运行脚本。
此时,坐标会发生变化,因此会单击不正确的点(区域)。
请通过对坐标进行归纳来解决此问题,而与机器分辨率无关。
用于单击特定坐标的代码如下:
Actions action = new Actions(getDriver());
action.moveByOffset(xcordinate, ycordinate).click().build().perform(); //coordinates changes as the resolution changes
Run Code Online (Sandbox Code Playgroud)