如何单击硒中“画布”的单个部分?

问题描述 投票:0回答:1

我试图单击特定部分,即图像的第一部分(19.9%),但它总是单击14.3%之后的任何值。请检查图像。[![https://i.stack.imgur.com/WoUlM.png]]

代码是:

<div class="tvimagesContainer" style="width: 80px; height: 241px;">
<canvas class="tabCanvas tab-widget" width="71" height="213" style="display: block; width: 80px; height: 237px;"></canvas>
</div>

我尝试过以下操作:

@FindBy(xpath="//*[@id='tabZoneId21']/div/div/div/div[1]/div[5]/div[1]/canvas")
WebElement wbcanvas;



Actions builder = new Actions(driver);
            Action drawAction = builder.moveToElement(wbcanvas, 213/12,10).// 
                      .click()
                      .build();
            drawAction.perform();

代替213 / 12,10放置了不同的值并尝试过,但是每次都单击图像的中间部分。任何帮助将不胜感激。

selenium
1个回答
0
投票

请尝试以下操作:

Actions actions = new Actions(driver);
actions.moveToElement(wbcanvas).moveByOffset(0, (213/12)).click().build();
drawAction.perform();
© www.soinside.com 2019 - 2024. All rights reserved.