У меня есть изображения с тегом <img>
или <canvas>
примерно 30 изображений. Мне нужно сделать выбор лассо, значит, нужно просто перетащить какую-то область, и drop сделает небольшой выбор из определенного изображения. И другая задача - щелкнуть любое значение% (см. Изображение). Обе задачи должны выполняться либо на <img>
, либо на <canvas>
.
Вот код HTML для тега изображения:
<div class="tab-tvView tvimagesNS" id="view801175643_62876675" tabindex="0" role="img" aria-describedby=" instructions8011595475643_628988876675" aria-labelledby="title815995343_62876675" style="background-color: rgb(255, 255, 255); left: 204px; top: 126px; width: 1426px; height: 288px;">
<div class="tvScrollContainer tvmodeRectSelect" data-tb-test-id="VisualizationScrollContainer" style="cursor: default; -webkit-tap-highlight-color: transparent; left: 0px; top: 0px; width: 1426px; height: 288px;">
<div class="tvBackgroundContainer"></div>
<div class="tvimagesContainer" style="background-color: rgb(255, 255, 255); width: 2761px; height: 15481px;">
<img src="/vizql/tilecache/B5BFF64B6FDF44839-:1/8630/784bfd8cb5ad8d46861ecefa5/views.80115943_628988876675.viz.0.0.png?=1588980460467Z2" style="left: 0px; top: 0px;"></div>
HTML код для тега Canvas:
<div class="tab-tvView tvimagesNS" id="viewview57400536391_623713079356" tabindex="0" role="img" aria-describedby=" instructions801475643_157832347816" aria-labelledby="title8011599643_15783612347816" style="background-color: rgb(255, 255, 255); left: 596px; top: 62px; width: 1022px; height: 215px;">
<div class="tvScrollContainer tvmodeRectSelect" data-tb-test-id="VisualizationScrollContainer" style="cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; left: 0px; top: 0px; width: 1022px; height: 215px;">
<div class="tvBackgroundContainer"></div>
<div class="tvimagesContainer" style="width: 1022px; height: 301px;">
<canvas class="tabCanvas tab-widget" width="1022" height="215" style="display: block; width: 1022px; height: 215px;"></canvas>
<canvas class="tabCanvas tab-widget" width="1022" height="215" style="display: block; position: absolute; left: 0px; top: 0px; width: 1022px; height: 215px;"></canvas></div>
canvas2 выбирается при выборе изображения
Я пробовал использовать Lasso Selection, будь то img или холст
public void lassoSelection() throws Exception {
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[title='data visualization']")));
Thread.sleep(10000);
WebElement window = driver.findElement(By.xpath("//div[@id='view8011599534815475643_6289886944926876675']/div/div[2]/img"));
action.moveToElement(window, 30, 30).clickAndHold().build().perform();
action.moveToElement(window, 300, 230).release().build().perform();
//new Actions(driver).moveToElement( window, 1, 1).clickAndHold().moveToElement( window, window.getSize().width-100, 100).release().perform();
System.out.println(window.getSize());
log.info("The area has been selected");
driver.switchTo().defaultContent();
}
Над кодом некоторое время работает какое-то время это не работает. И чтобы щелкнуть по конкретному% (см. Изображение), я пробовал:
WebElement patient = driver.findElement(By.xpath("//div[@id='view5740053158935886391_623713095327079356']/div/div[2]/canvas[2]"));
Actions act = new Actions(driver);
act.moveByOffset(20, 30);
act.moveToElement(patient).click();
[https://i.stack.imgur.com/J9INM.png] Любая помощь будет принята с благодарностью!