@Override public Match findElement(int numRetries) { Match match = null; for (int i = 0; i <= numRetries; i++) { try { Region region = labelObj .getLabelImageLocation() .getRegionOfImageObject(browser, labelObj.getLabelImage()); Assert.assertNotNull(region, "Failed to find Label '" + labelObj.getDisplayName() + "'."); match = new Match(region, 1); break; } catch (Throwable th) { if (i == numRetries) { Assert.fail( "Unable to find Label '" + labelObj.getDisplayName() + "'. Reason timeout(waited for " + (numRetries * 2) + " seconds).", th); break; } } browser.waitForSeconds(2); } return match; }
@Override public List<Match> findElements(int numRetries) { Region r = labelObj.getLabelImageLocation().getRegion(browser); return new ImageObject(UIObjectType.label, labelObj.getDisplayName(), labelObj.getLabelImage()) .getValidator(browser, r) .findElements(numRetries); }
public void click(ImageSection imageSection, int numRetries) { try { Match match = findElement(numRetries); getImageSection(match, imageSection).click(); } catch (Throwable th) { Assert.fail( "Failed to perform mouse click on Label '" + labelObj.getDisplayName() + "'.", th); } }
@Override public void doubleClick(int numRetries) { try { Match match = findElement(numRetries); match.doubleClick(); } catch (Throwable th) { Assert.fail( "Failed to perform mouse double click on Label '" + labelObj.getDisplayName() + "'.", th); } }
@Override public void performKeyDown(Keys keys, int numRetries) { try { Match match = findElement(numRetries); match.click(); match.keyDown(seleniumToSikuliKeyConverter(keys)); } catch (Throwable th) { Assert.fail("Failed to perform keyDown on Label '" + labelObj.getDisplayName() + "'.", th); } }
@Override public void release(int numRetries) { try { Match match = findElement(numRetries); match.mouseDown(Button.LEFT); } catch (Throwable th) { Assert.fail( "Failed to perform mouse clickAndHold on Label '" + labelObj.getDisplayName() + "'.", th); } }
public void dragAndDrop(ImageObject target, Region targetRegion, int numRetries) { try { Match sourceElem = findElement(numRetries); Match targetElem = target.getValidator(browser, targetRegion).findElement(numRetries); Assert.assertNotNull(sourceElem, "Failed to find Label '" + labelObj.getDisplayName() + "'."); Assert.assertNotNull(targetElem, "Failed to find element '" + target.getDisplayName() + "'."); sourceElem.drag(targetElem); sourceElem.dropAt(targetElem); } catch (Throwable th) { Assert.fail( "Failed to perform dragAndDrop from source '" + labelObj.getDisplayName() + "' to target '" + target.getDisplayName() + "'.", th); } }