Search in sources :

Example 1 with Pattern

use of org.sikuli.script.Pattern in project selenium_java by sergueik.

the class AppTest method testUpload.

@Ignore
@Test
public // https://www.youtube.com/watch?v=8OfnQEfzfmw
void testUpload() {
    String openButtonImage = fullPath("open_1920x1080.png");
    Pattern filenameTextBox = new Pattern(fullPath("filename_1920x1080.png"));
    driver.navigate().to(getPageContent("upload.html"));
    try {
        File tmpFile = File.createTempFile("foo", ".png");
        WebElement element = driver.findElement(By.tagName("input"));
        element.click();
        try {
            screen.exists(openButtonImage, sikuliTimeout);
            screen.type(filenameTextBox, tmpFile.getCanonicalPath());
            System.out.println("Uploading: " + tmpFile.getCanonicalPath());
            screen.click(openButtonImage, 0);
        } catch (FindFailed e) {
            verificationErrors.append(e.toString());
        }
        try {
            element = driver.findElement(By.tagName("input"));
            highlight(element);
            assertThat(element.getAttribute("value"), containsString(tmpFile.getName()));
        } catch (Error e) {
            verificationErrors.append(e.toString());
        }
    } catch (IOException e) {
        throw new RuntimeException(e.toString());
    }
}
Also used : Pattern(org.sikuli.script.Pattern) RuntimeException(java.lang.RuntimeException) FindFailed(org.sikuli.script.FindFailed) IOException(java.io.IOException) WebElement(org.openqa.selenium.WebElement) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with Pattern

use of org.sikuli.script.Pattern 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;
}
Also used : Pattern(org.sikuli.script.Pattern) FindFailed(org.sikuli.script.FindFailed) Match(org.sikuli.script.Match)

Aggregations

FindFailed (org.sikuli.script.FindFailed)2 Pattern (org.sikuli.script.Pattern)2 File (java.io.File)1 IOException (java.io.IOException)1 RuntimeException (java.lang.RuntimeException)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 WebElement (org.openqa.selenium.WebElement)1 Match (org.sikuli.script.Match)1