无法使用Action类在图像上绘制线条

时间:2018-02-01 14:44:48

标签: selenium-webdriver

我试过不同版本的硒。以下是代码。

<ReferenceInput  source="CompanyID" reference="companies" allowEmpty alwaysOn>
<SelectInput optionText={choice => `${choice.name}`} />
</ReferenceInput>

<DependentInput dependsOn="CompanyID" >
<ReferenceInput  source="BranchID" reference="branches" allowEmpty alwaysOn>
<SelectInput optionText={choice => `${choice.tmima  +" "+ choice.address}`} />
</ReferenceInput>
</DependentInput>

它在图像上绘制线条,但不释放鼠标,因此不会保存线条。

1 个答案:

答案 0 :(得分:0)

你需要在perfrom()之前调用release()方法。请参阅此link

WebElement element = driver.findElement(By.xpath(".//*[@id='imageViewer']"));
Actions builder = new Actions(driver);  
builder.moveToElement(element, 785,322);
builder.clickAndHold();
builder.moveToElement(element, 1130, 261);
builder.release();
builder.perform(); //no need to call build() directly call perform()
Thread.sleep(10000);