Search in sources :

Example 1 with FindFailed

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

the class AppTest method testSikuliFindBasic.

@Ignore
@Test
public // /blob/master/src/test/java/net/phptravels/home/HeaderTopOnFirefox.java
void testSikuliFindBasic() {
    int width = 800;
    int height = 600;
    driver.manage().window().setSize(new Dimension(width, height));
    String spanishFlagImage = fullPath("spanish_flag.png");
    driver.get("http://phptravels.net/en");
    WebElement languageElement = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//div[contains(@class, 'navbar')]//a[@class='dropdown-toggle']"))));
    assertThat(languageElement, notNullValue());
    highlight(languageElement);
    languageElement.click();
    try {
        if (screen.exists(spanishFlagImage, sikuliTimeout) != null) {
            System.err.println("Found spanish flag image.");
            screen.click(spanishFlagImage, 0);
        }
    } catch (FindFailed e) {
        System.err.println("Can not Find flag image.");
        verificationErrors.append(e.toString());
    }
    wait.until(ExpectedConditions.urlToBe("http://phptravels.net/es"));
    try {
        Thread.sleep(100);
    } catch (InterruptedException e) {
    }
}
Also used : FindFailed(org.sikuli.script.FindFailed) Dimension(org.openqa.selenium.Dimension) WebElement(org.openqa.selenium.WebElement) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with FindFailed

use of org.sikuli.script.FindFailed 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 3 with FindFailed

use of org.sikuli.script.FindFailed in project sakuli by ConSol.

the class RegionImpl method findRegion.

/**
 * {@link Region#findRegion(Region)}
 */
public RegionImpl findRegion(RegionImpl region) {
    Match match;
    try {
        match = this.find(region);
    } catch (FindFailed findFailed) {
        match = null;
    }
    if (match != null) {
        return toRegion(match);
    }
    loader.getExceptionHandler().handleException("Can't find \"" + region + "\" in this region!", this, resumeOnException);
    return null;
}
Also used : FindFailed(org.sikuli.script.FindFailed) Match(org.sikuli.script.Match)

Example 4 with FindFailed

use of org.sikuli.script.FindFailed in project sakuli by ConSol.

the class RegionImpl method rightClickMe.

/**
 * {@link Region#rightClick()} ()}
 */
public RegionImpl rightClickMe() {
    int ret;
    try {
        Location center = this.getCenter();
        ret = this.rightClick(center);
    } catch (FindFailed findFailed) {
        ret = 0;
    }
    loader.loadSettingDefaults();
    if (ret != 1) {
        loader.getExceptionHandler().handleException("Couldn't right click on region " + this, this, resumeOnException);
        return null;
    }
    return this;
}
Also used : FindFailed(org.sikuli.script.FindFailed) Location(org.sikuli.script.Location)

Example 5 with FindFailed

use of org.sikuli.script.FindFailed in project sakuli by ConSol.

the class RegionImpl method doubleClickMe.

/**
 * {@link Region#doubleClick()} ()}
 */
public RegionImpl doubleClickMe() {
    int ret;
    try {
        Location center = this.getCenter();
        ret = this.doubleClick(center);
    } catch (FindFailed findFailed) {
        ret = 0;
    }
    loader.loadSettingDefaults();
    if (ret != 1) {
        loader.getExceptionHandler().handleException("Couldn't double click on region " + this, this, resumeOnException);
        return null;
    }
    return this;
}
Also used : FindFailed(org.sikuli.script.FindFailed) Location(org.sikuli.script.Location)

Aggregations

FindFailed (org.sikuli.script.FindFailed)11 Location (org.sikuli.script.Location)4 Ignore (org.junit.Ignore)3 Test (org.junit.Test)3 WebElement (org.openqa.selenium.WebElement)3 Match (org.sikuli.script.Match)3 Pattern (org.sikuli.script.Pattern)2 File (java.io.File)1 IOException (java.io.IOException)1 Boolean (java.lang.Boolean)1 RuntimeException (java.lang.RuntimeException)1 ArrayList (java.util.ArrayList)1 Dimension (org.openqa.selenium.Dimension)1 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)1 ImageLibObject (org.sakuli.datamodel.actions.ImageLibObject)1 Screen (org.sikuli.script.Screen)1 Test (org.testng.annotations.Test)1