use of org.sikuli.script.FindFailed in project selenium_java by sergueik.
the class AppTest method testCalendar.
@Ignore
@Test
public void testCalendar() {
driver.navigate().to(getPageContent("calendar.html"));
WebElement calendarElement = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.cssSelector("input[name='calendar']"))));
int xOffset = calendarElement.getSize().getWidth() - 2;
int yOffset = calendarElement.getSize().getHeight() - 2;
System.err.println(String.format("Hover at (%d, %d)", xOffset, yOffset));
actions.moveToElement(calendarElement, xOffset, yOffset).build().perform();
// Sometimes hover is not enough here for some reason
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
actions.moveToElement(calendarElement, xOffset, yOffset).click().build().perform();
String calendarDropDownImage = fullPath("calendar_dropdown_1920x1080.png");
try {
screen.exists(calendarDropDownImage, sikuliTimeout);
screen.click(calendarDropDownImage, 0);
} catch (FindFailed e) {
verificationErrors.append(e.toString());
}
// Month Navigation
String monthNavigateImage = fullPath("month_navigate_1920x1080.png");
match = screen.exists(monthNavigateImage, sikuliTimeout);
// Sikuli highlight method would force the Chrome native calendar to close
// only useful for debugging during script development
// match.highlight((float) 3.0);
match.offset(-32, 0).click();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
match = screen.exists(monthNavigateImage, sikuliTimeout);
match.offset(32, 0).click();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
// Year Navigation
String yearDropdownImage = "year_dropdown_1920x1080.png";
match = screen.exists(fullPath(yearDropdownImage), sikuliTimeout);
match.offset(-40, 0).click();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
ArrayList<String> yearImages = new ArrayList<>(Arrays.asList(new String[] { "jan_1920x1080.png", "jan_highlight_1920x1080.png" }));
Boolean done = false;
for (String image : yearImages) {
if (!done) {
match = screen.exists(fullPath(image), sikuliTimeout);
if (match != null) {
String text = match.text();
System.err.format("Sikuli read: '%s'\n", text);
// if --- no text --- is printed
// make sure tessdata is copied to
// ${env:APPDATA}\Sikulix\SikulixTesseract\tessdata
match.click();
done = true;
}
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
use of org.sikuli.script.FindFailed in project selenium_java by sergueik.
the class ChromeExtensionSikuliTest method openExtensionPopupTest.
@Test(priority = 1, enabled = false)
public void openExtensionPopupTest() {
Screen screen = new Screen();
String imagePath = getResourcePath("chropath.png");
try {
screen.find(imagePath);
screen.click(imagePath);
} catch (FindFailed e) {
e.printStackTrace();
}
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.numberOfWindowsToBe(2));
String parentWindow = driver.getWindowHandle();
Set<String> allWindows = driver.getWindowHandles();
for (String curWindow : allWindows) {
if (!parentWindow.equals(curWindow)) {
driver.switchTo().window(curWindow);
}
}
}
use of org.sikuli.script.FindFailed in project sakuli by ConSol.
the class RegionImpl method clickMe.
/**
* {@link org.sakuli.actions.screenbased.Region#click()}
*/
public RegionImpl clickMe() {
int ret;
try {
Location center = this.getCenter();
ret = this.click(center);
} catch (FindFailed findFailed) {
ret = 0;
}
loader.loadSettingDefaults();
if (ret != 1) {
loader.getExceptionHandler().handleException("Couldn't click on region " + this, this, resumeOnException);
return null;
}
return this;
}
use of org.sikuli.script.FindFailed in project sakuli by ConSol.
the class RegionImpl method mouseMoveMe.
/**
* wrapper implementation for {@link #mouseMove(Object)} ()}
*/
public RegionImpl mouseMoveMe() {
int ret;
try {
Location center = this.getCenter();
ret = this.mouseMove(center);
} catch (FindFailed findFailed) {
ret = 0;
}
loader.loadSettingDefaults();
if (ret != 1) {
loader.getExceptionHandler().handleException("Could not move the mouse on region " + this, this, resumeOnException);
return null;
}
return this;
}
use of org.sikuli.script.FindFailed in project sakuli by ConSol.
the class RegionImpl method find.
/**
* {@link Region#find(String)}.
*/
public RegionImpl find(String imageName) {
Match match;
Pattern imagePattern = loadPattern(imageName);
try {
match = this.find(imagePattern);
} catch (FindFailed findFailed) {
match = null;
}
if (match != null) {
return toRegion(match);
}
loader.getExceptionHandler().handleException("Can't find \"" + imagePattern + "\" in " + this.toString(), this, resumeOnException);
return null;
}
Aggregations