Example usage for org.openqa.selenium By linkText

List of usage examples for org.openqa.selenium By linkText

Introduction

In this page you can find the example usage for org.openqa.selenium By linkText.

Prototype

public static By linkText(String linkText) 

Source Link

Usage

From source file:com.github.fscheffer.arras.demo.LightboxIT.java

License:Apache License

@Test
public void testInlined() {

    // inline/*  ww  w . j ava  2  s .  c  om*/
    openLightbox(By.linkText("Show Kafka!"));

    waitUntil(containsText("#cboxLoadedContent h3", "Kafka"));

    closeLightbox();
}

From source file:com.github.fscheffer.arras.demo.LightboxIT.java

License:Apache License

@Test
public void testZoneUpdate() {

    openLightbox(By.linkText("Some ajax event"));

    waitUntil(containsText("#cboxLoadedContent h3", "Updated zone at"));

    closeLightbox();/*www  . j a v a 2 s  .c  o m*/
}

From source file:com.github.fscheffer.arras.demo.LightboxIT.java

License:Apache License

@Test
public void testLightboxInZone() {

    element(By.linkText("Trigger zone")).click();

    waitForAjaxRequestsToComplete();//from   www.jav  a2s.  co  m

    waitUntil(containsText("#lightboxZone", "Stornetta in a Zone"));
    waitUntil(containsText("#lightboxZone", "Show content with zone"));

    // check Lightbox
    openLightbox(By.linkText("Stornetta in a Zone"));

    assertImageInLightbox("/arras/assets/meta/dedf595e/photos/landscape/man_point-arena-stornetta.jpg");

    closeLightbox();

    // check LightboxBody
    openLightbox(By.linkText("Show content with zone"));

    waitUntil(containsText("#cboxLoadedContent h3", "Content loaded by Zone"));

    closeLightbox();
}

From source file:com.github.fscheffer.arras.demo.MediumEditorIT.java

License:Apache License

@BeforeMethod
public void before() {
    try {// www.j a va  2 s  . c o m
        open("/MediumEditorDemo");
        element(By.linkText("Reset demo")).click();
        waitUntil(pageHasLoaded());
    } catch (Exception e) {
        log.error("Exception: ", e);
    }
}

From source file:com.github.fscheffer.arras.demo.TabGroupIT.java

License:Apache License

@Test
public void testTabInZone() {

    element(By.linkText("trigger zone")).click();

    waitForAjaxRequestsToComplete();/*ww w .j  ava  2s .c o  m*/

    waitUntil(containsText("#tabgroupZone", "a tab in a zone"));

    element(By.linkText("Tab In Zone2")).click();

    waitUntil(containsText("#tabgroupZone", "another tab in the same zone"));
}

From source file:com.github.iexel.fontus.web.test.SeleniumIT.java

License:Apache License

@Test
public void testProductsPage() throws Exception {
    // the delay is for an increased dramatic effect only :)
    int demoWaitTime = 2000;

    driver.get(baseUrl + "/about");
    driver.findElement(By.linkText("Products & Invoices")).click();

    driver.findElement(By.id("j_username")).clear();
    driver.findElement(By.id("j_username")).sendKeys("admin");
    driver.findElement(By.id("j_password")).clear();
    driver.findElement(By.id("j_password")).sendKeys("admin");
    Thread.sleep(demoWaitTime);/*w  w w . ja  va 2s  .c om*/
    driver.findElement(By.cssSelector("input.button")).click();
    Thread.sleep(demoWaitTime);

    driver.findElement(By.xpath("//tr[@id='4']/td[2]")).click();
    driver.findElement(By.id("editBtn")).click();
    Thread.sleep(demoWaitTime);
    driver.findElement(By.id("name")).clear();
    driver.findElement(By.id("price")).clear();
    driver.findElement(By.id("price")).sendKeys("45.50 a");
    Thread.sleep(demoWaitTime);
    driver.findElement(By.id("sData")).click();
    Thread.sleep(demoWaitTime);

    assertPresent("#tr_name .field-error-message");
    assertPresent("#tr_price .field-error-message");

    driver.findElement(By.id("cData")).click();
    Thread.sleep(demoWaitTime);

    driver.findElement(By.id("editBtn")).click();
    Thread.sleep(demoWaitTime);
    driver.findElement(By.id("price")).clear();
    driver.findElement(By.id("price")).sendKeys("45.51");
    Thread.sleep(demoWaitTime);
    driver.findElement(By.id("sData")).click();
    Thread.sleep(demoWaitTime);
    driver.findElement(By.cssSelector("span.ui-icon.ui-icon-seek-next")).click();
    Thread.sleep(demoWaitTime);
    driver.findElement(By.cssSelector("span.ui-icon.ui-icon-seek-prev")).click();
    Thread.sleep(demoWaitTime);

    assertEquals("$ 45.51", driver.findElement(By.xpath("//tr[@id='4']/td[3]")).getText());

    driver.findElement(By.xpath("//tr[@id='4']/td[2]")).click();
    driver.findElement(By.id("editBtn")).click();
    Thread.sleep(demoWaitTime);
    driver.findElement(By.id("price")).clear();
    driver.findElement(By.id("price")).sendKeys("45.50");
    Thread.sleep(demoWaitTime);
    driver.findElement(By.id("sData")).click();
    Thread.sleep(demoWaitTime);
    driver.findElement(By.cssSelector("span.ui-icon.ui-icon-seek-next")).click();
    Thread.sleep(demoWaitTime);
    driver.findElement(By.cssSelector("span.ui-icon.ui-icon-seek-prev")).click();

    assertEquals("$ 45.50", driver.findElement(By.xpath("//tr[@id='4']/td[3]")).getText());

    Thread.sleep(demoWaitTime);
    driver.findElement(By.linkText("Logout: admin")).click();
}

From source file:com.github.lucasgueiros.whist.partida.PartidaWebIT.java

@Test
public void testJogoContraMaquinas() {
    driver.get(baseUrl + "/ifuwhist/");
    driver.findElement(By.linkText("Entrar")).click();
    driver.findElement(By.id("oform:oLoginField")).clear();
    driver.findElement(By.id("oform:oLoginField")).sendKeys("usuario1");
    driver.findElement(By.id("oform:oSenhaField")).clear();
    driver.findElement(By.id("oform:oSenhaField")).sendKeys("123");
    driver.findElement(By.partialLinkText("Criar mesa")).click();
    driver.findElement(By.id("formulario:campoNome")).clear();
    driver.findElement(By.id("formulario:campoNome")).sendKeys("sala");
    driver.findElement(By.partialLinkText("Um contra maquinas")).click();
    driver.findElement(By.partialLinkText("Entrar em uma sala")).click();
    driver.findElement(By.partialLinkText("Entrar")).click();
    driver.findElement(By.partialLinkText("Eu quero jogar")).click();
    driver.findElement(By.partialLinkText("Comecar a jogar")).click();
}

From source file:com.github.swt_release_fetcher.Main.java

License:Apache License

public static void main(String[] args) throws Exception {

    for (String arg : args) {
        if (arg.equals("--deploy")) {
            deployArtifacts = true;//  w  w  w.  j  a v  a 2  s  .c om
        }
        if (arg.equals("--help")) {
            showHelp();
        }
        if (arg.equals("--debug")) {
            debug = true;
        }
        if (arg.equals("--silent")) {
            silentMode = true;
        }
    }

    // the mirror we use for all following downloads
    String mirrorUrl = "";

    // lightweight headless browser
    WebDriver driver = new HtmlUnitDriver();

    // determine if the website has changed since our last visit
    // stop if no change was detected
    // Ignore this check if we just want to deploy
    if (!deployArtifacts) {
        SwtWebsite sw = new SwtWebsite();

        try {
            if (!sw.hasChanged(driver, WEBSITE_URL)) {
                // exit if no change was detected
                printSilent("SWT website hasn't changed since our last visit. Stopping here.");
                driver.quit();
                System.exit(0);
            } else {
                // proceed if the site has changed
                System.out
                        .println("Page change detected! You may want to run the script in deploy mode again.");
            }
        } catch (IOException ioe) {
            System.out.println(ioe.getMessage());
        }
    }

    // get SWT's main site
    printDebug("Parsing eclipse.org/swt to find a mirror");
    driver.get(WEBSITE_URL);
    printDebug(WEBSITE_URL);

    // find the stable release branch link and hit it
    final List<WebElement> elements = driver.findElements(By.linkText("Linux"));
    final String deeplink = elements.get(0).getAttribute("href");
    printDebug("deeplink: " + deeplink);
    driver.get(deeplink);

    // get the direct download link from the next page
    final WebElement directDownloadLink = driver.findElement(By.linkText("Direct link to file"));
    printDebug("direct download link: " + directDownloadLink.getAttribute("href"));

    // the direct link again redirects, here is our final download link!
    driver.get(directDownloadLink.getAttribute("href"));
    final String finalDownloadLink = driver.getCurrentUrl();
    printDebug("final download link: " + finalDownloadLink);

    // Close the browser
    driver.quit();

    // extract the mirror URL for all following downloads
    String[] foo = finalDownloadLink.split("\\/", 0);
    final String filename = foo[foo.length - 1];
    mirrorUrl = (String) finalDownloadLink.subSequence(0, finalDownloadLink.length() - filename.length());
    // debug output
    printDebug("full download url: " + finalDownloadLink);
    printDebug("mirror url: " + mirrorUrl);

    // determine current release name
    String[] releaseName = filename.split("-gtk-linux-x86.zip");
    String versionName = releaseName[0].split("-")[1];
    System.out.println("current swt version: " + versionName);

    // TODO move to properties file
    PackageInfo[] packages = {
            // Win32
            new PackageInfo("win32-win32-x86.zip", "org.eclipse.swt.win32.win32.x86"),
            new PackageInfo("win32-win32-x86_64.zip", "org.eclipse.swt.win32.win32.x86_64"),
            // Linux
            new PackageInfo("gtk-linux-ppc.zip", "org.eclipse.swt.gtk.linux.ppc"),
            new PackageInfo("gtk-linux-ppc64.zip", "org.eclipse.swt.gtk.linux.ppc64"),
            new PackageInfo("gtk-linux-x86.zip", "org.eclipse.swt.gtk.linux.x86"),
            new PackageInfo("gtk-linux-x86_64.zip", "org.eclipse.swt.gtk.linux.x86_64"),
            new PackageInfo("gtk-linux-s390.zip", "org.eclipse.swt.gtk.linux.s390"),
            new PackageInfo("gtk-linux-s390x.zip", "org.eclipse.swt.gtk.linux.s390x"),
            // OSX
            new PackageInfo("cocoa-macosx.zip", "org.eclipse.swt.cocoa.macosx"),
            new PackageInfo("cocoa-macosx-x86_64.zip", "org.eclipse.swt.cocoa.macosx.x86_64"),
            // Additional platforms
            new PackageInfo("gtk-aix-ppc.zip", "org.eclipse.swt.gtk.aix.ppc"),
            new PackageInfo("gtk-aix-ppc64.zip", "org.eclipse.swt.gtk.aix.ppc64"),
            new PackageInfo("gtk-hpux-ia64.zip", "org.eclipse.swt.gtk.hpux.ia64"),
            new PackageInfo("gtk-solaris-sparc.zip", "org.eclipse.swt.gtk.solaris.sparc"),
            new PackageInfo("gtk-solaris-x86.zip", "org.eclipse.swt.gtk.solaris.x86") };

    File downloadDir = new File("downloads");
    if (!downloadDir.exists()) {
        downloadDir.mkdirs();
    }

    for (PackageInfo pkg : packages) {
        final String zipFileName = releaseName[0] + "-" + pkg.zipName;
        final URL downloadUrl = new URL(mirrorUrl + zipFileName);
        final URL checksumUrl = new URL(mirrorUrl + "checksum/" + zipFileName + ".md5");

        System.out.print("* Downloading " + pkg.zipName + " ... ");
        Artifact artifact = new Artifact(new File(downloadDir, zipFileName), versionName, pkg.artifactId);
        artifact.downloadAndValidate(downloadUrl, checksumUrl);

        if (deployArtifacts) {
            artifact.deploy();
        }
    }
}

From source file:com.googlecode.ounit.test.moodle19.QuizPage.java

License:Open Source License

@Override
public void navigate(int i) {
    log("Navigating to question " + i);
    pagingBar.findElement(By.linkText(i + "")).click();
}

From source file:com.hotwire.selenium.bex.BexAbstractPage.java

License:Open Source License

/**
 * Use it if select on webpage is invisible and decorated by links
 * @param selectLinkCss  - visible selector link
 * @param linkText   - text of the link in selector
 *//*w w w .ja va 2  s  .c  o  m*/
protected void selectLink(String selectLinkCss, String linkText) {
    getWebDriver().findElement(By.cssSelector(selectLinkCss)).click();
    new WebDriverWait(getWebDriver(), DEFAULT_WAIT)
            .until(ExpectedConditions.visibilityOfElementLocated(By.linkText(linkText))).click();
}