Example usage for org.openqa.selenium.firefox FirefoxDriver findElementsByLinkText

List of usage examples for org.openqa.selenium.firefox FirefoxDriver findElementsByLinkText

Introduction

In this page you can find the example usage for org.openqa.selenium.firefox FirefoxDriver findElementsByLinkText.

Prototype

@Override
    public List<WebElement> findElementsByLinkText(String using) 

Source Link

Usage

From source file:sf.wicklet.ext.test.arquillian.Test01.java

License:Apache License

@Test
public void test01(@ArquillianResource final URL httpContext) throws Exception {
    final StepWatch timer = new StepWatch(true);
    final FirefoxProfile profile = new FirefoxProfile(new File("../opt/firefox/7x16slsr.default"));
    profile.setPreference("network.dns.disableIPv6", true);
    final FirefoxDriver driver = new FirefoxDriver(profile);
    try {/*from  www.j a va 2s.  c o m*/
        if (Test01.DEBUG.isDebug()) {
            System.out.println(timer.toString("# Client start"));
        }
        driver.get(new URL(httpContext, TestAccordion01Page.MNT_PATH).toString());
        final String title = driver.getTitle();
        if (Test01.DEBUG.isDebug()) {
            System.out.println(timer.toString("Page title is: " + title));
            System.out.println(driver.getPageSource());
        }
        Assert.assertEquals("Test", driver.getTitle());
        final List<WebElement> p1 = driver.findElementsByLinkText("Panel1");
        final List<WebElement> p2 = driver.findElementsByLinkText("Panel2");
        final List<WebElement> p3 = driver.findElementsByLinkText("Panel3");
        final List<WebElement> c1 = driver.findElementsById("content1");
        final List<WebElement> c2 = driver.findElementsById("content2");
        final List<WebElement> c3 = driver.findElementsById("content3");
        Assert.assertEquals(1, p1.size());
        Assert.assertEquals(1, p2.size());
        Assert.assertEquals(1, p3.size());
        Assert.assertEquals(1, c1.size());
        Assert.assertEquals(1, c2.size());
        Assert.assertEquals(1, c3.size());
        Assert.assertEquals("", c2.get(0).getAttribute("style"));
        //
        p2.get(0).click();
        if (Test01.DEBUG.isDebug()) {
            System.out.println(driver.getPageSource());
        }
        final List<WebElement> cc1 = driver.findElementsById("content1");
        final List<WebElement> cc2 = driver.findElementsById("content2");
        final List<WebElement> cc3 = driver.findElementsById("content3");
        Assert.assertEquals(1, cc1.size());
        Assert.assertEquals(1, cc2.size());
        Assert.assertEquals(1, cc3.size());
        Assert.assertEquals("display: none;", cc2.get(0).getAttribute("style"));
        //
        p2.get(0).click();
        if (Test01.DEBUG.isDebug()) {
            System.out.println(driver.getPageSource());
        }
        final List<WebElement> ccc2 = driver.findElementsById("content2");
        Assert.assertEquals(1, ccc2.size());
        Assert.assertEquals("display: block;", ccc2.get(0).getAttribute("style"));
    } finally {
        if (Test01.DEBUG.isDebug()) {
            final String text = driver.getPageSource();
            FileUtil.writeFile(Test01.test01Html, false, text);
            SeleniumTestUtil.takeScreenshot(driver, Test01.test01Png);
            System.out.println(timer.toString("# Client done"));
        }
        if (Test01.DEBUG.isDebugServer()) {
            System.in.read();
        } else {
            driver.quit();
        }
    }
}