Example usage for org.openqa.selenium WebElement click

List of usage examples for org.openqa.selenium WebElement click

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement click.

Prototype

void click();

Source Link

Document

Click this element.

Usage

From source file:StoryKeyboardShortcutTests.java

@Test
public void storyKeyboardMute() throws InterruptedException {

    //1. Go to story site
    driver.get(//www  . j av a 2  s  . com
            "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc");
    //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

    WebDriverWait wait = new WebDriverWait(driver, 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")));

    //2. Close the license popup
    WebElement okButton = driver.findElement(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"));
    okButton.click();

    //Click on Media tab
    WebElement uploadButton = driver.findElement(
            By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td"));
    uploadButton.click();

    //Click on video tab
    WebElement videoTab = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[1]/div/div/div/table[1]/tbody[2]/tr[1]/td[1]/div/div/div[2]"));
    videoTab.click();
    WebElement searchText = driver.findElement(By.id("isc_30"));
    searchText.sendKeys("SSS_2477_01.mov");

    Thread.sleep(5000);
    WebElement selectVideo = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div[1]/div[3]"));

    selectVideo.click();

    WebElement selectVideo1 = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div[1]/div[3]"));
    selectVideo1.click();

    /*
            Thread.sleep(2000) ;
            WebElement timeLine = driver.findElement(By.cssSelector("svg[id=multimedia_ClearInOut]"));
            timeLine.click();
            
            Thread.sleep(2000);
            int xp1=0;
            WebElement testtimecode1 = driver.findElement(By.xpath("//*[contains(text(),'00:0"+xp1+":')]"));
            final String starttime = testtimecode1.getText();
            
            Actions action = new Actions(driver);
            action.sendKeys(Keys.SPACE).build().perform();
            System.out.println(testtimecode1.getText());
            
            int ourtime = 9000;
            Thread.sleep(ourtime);
            int xp = (ourtime-1000)/1000;
            action.sendKeys(Keys.SPACE).build().perform();
            Thread.sleep(2000);
            
            timeLine.click();
            Thread.sleep(2000);
            WebElement testtimecode = driver.findElement(By.xpath("//*[contains(text(),'00:0"+xp+":')]"));
            
            System.out.println(testtimecode.getText());
            System.out.println(testtimecode1.getText());
            
            Assert.assertNotEquals(testtimecode.getText(), starttime);
            //Assert.assertNotEquals("111", "1");
    */
}

From source file:CakeHomePageTest.java

private void clickNavElm(String elm) {

    List<WebElement> elms = driver.findElements(By.cssSelector(".navbar-inner .nav li a"));

    for (WebElement element : elms) {
        System.out.println(element.getText());
        if (elm.equals(element.getText())) {
            element.click();
            return;
        }//w w  w .j a  v  a 2s.com
    }

}

From source file:CakeHomePageTest.java

@Test
public void software() throws IOException {
    //WebElement button = driver.findElement(By.linkText("/pricing/"));
    clickNavElm("Software");
    WebElement button = driver.findElement(By.id("have-taste-btn"));
    button.click();

    List<WebElement> elements = driver.findElements(By.cssSelector(".entry-title"));
    Boolean isRightPage = false;/* ww  w  .j ava2  s . c  o  m*/
    for (WebElement element : elements) {
        if ("Insights delivered to your dashboard at the touch of a button.".equals(element.getText())) {
            isRightPage = true;
        }
    }
    if (!isRightPage) {

        fail("Not on the right page!");
    }
}

From source file:seleniumTester.java

@Test
public void test_4() {
    WebElement element = driver.findElement(By.id("h_year"));
    element.click();
    WebElement e = driver.findElement(By.tagName("tbody"));
    List<WebElement> rows = e.findElements(By.tagName("tr"));

    WebElement firstRow = rows.get(0);/*w ww. j a va 2  s.  c  om*/
    String firstRow_id = firstRow.findElement(By.tagName("td")).getText();
    WebElement lastRow = rows.get((rows.size() - 1));
    String lastRow_id = lastRow.findElement(By.tagName("td")).getText();

    Assert.assertThat(firstRow_id, is("938"));
    Assert.assertThat(lastRow_id, is("940"));
}

From source file:LoginScreenGrapheneTest.java

@Test
@RunAsClient/*from   w ww. j a v  a  2s.  c  om*/
public void ShouldBePosibleToSearchTestowkaAtGoogle() throws InterruptedException {
    browser.get("http://google.pl");
    WebElement searchField = browser.findElement(By.name("q"));
    searchField.sendKeys("testowka.pl");
    WebElement searchButton = browser.findElement(By.id("sblsbb"));
    searchButton.click();
    for (int second = 0;; second++) {
        if (second >= 60)
            fail("timeout");
        try {
            if (browser.findElement(By.linkText("Testowka.pl")).isDisplayed()) {
                break;
            }
        } catch (Exception e) {
        }
        Thread.sleep(1000);
    }
    WebElement linkToTestowka = browser.findElement(By.linkText("Testowka.pl"));
    linkToTestowka.click();
}

From source file:LoginScreenGrapheneTest.java

@Test
@RunAsClient//from w w w  .j a  va 2 s  .c o m
public void should_return_sport_news() {
    browser.get("http://sportowefakty.pl");
    WebElement footballLink = browser.findElement(By.linkText("Pika nona"));
    footballLink.click();
    WebElement ekstraklasaLink = browser.findElement(By.linkText("Ekstraklasa"));
    ekstraklasaLink.click();
    System.out.println();
}

From source file:TestaCadastroProcesso.java

@Test(groups = "login")
public void testaLoginSiapcon() throws Exception {

    driver.navigate().to("http://52.1.49.37/SIAPCON_SPRINT11/");

    DefaultThrowTreatment def = new DefaultThrowTreatment();

    // verifica se os elementos existem
    def.verifyElementPresenceById(driver, "RichWidgets_wt33:wtMainContent:wtUserNameInput");
    def.verifyElementPresenceById(driver, "RichWidgets_wt33:wtMainContent:wtPasswordInput");
    def.verifyElementPresenceById(driver, "RichWidgets_wt33:wtMainContent:wtLoginButton");

    // caso exista escreve
    WebElement inputUser = driver.findElement(By.id("RichWidgets_wt33:wtMainContent:wtUserNameInput"));
    WebElement inputPasswd = driver.findElement(By.id("RichWidgets_wt33:wtMainContent:wtPasswordInput"));
    WebElement buttonLogin = driver.findElement(By.id("RichWidgets_wt33:wtMainContent:wtLoginButton"));

    // escreve as informaes=
    inputUser.sendKeys("claudiana.coelho");
    inputPasswd.sendKeys("123456");

    // clica no boto
    buttonLogin.click();
}

From source file:TestaCadastroProcesso.java

@Test(dependsOnGroups = "login", groups = "required")
public void testaMsgNumero() throws Exception {

    driver.navigate()/*from  www  . j  av  a 2  s  . com*/
            .to("http://52.1.49.37/SIAPCON_SPRINT11/ListarProcessos.jsf?(Not.Licensed.For.Production)=");

    driver.navigate().to(
            "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)=");

    // gera um tempo de espera para a pgina carregar e o elemento ser renderizado
    driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);

    try {

        // insere um numero de processo valido
        WebElement numero = driver
                .findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget"));
        numero.sendKeys("000");

        // clica no boto submit
        WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38"));
        submit.click();

        // Espera at que o elemento que contm a msg de erro esteja vsivel
        WebDriverWait wait = new WebDriverWait(driver, 30);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("Feedback_Message_Error")));

        // testa se a msg de obrigatoriedade est sendo exibida
        if (!driver.findElement(By.className("Feedback_Message_Error")).isDisplayed()) {
            Assert.fail("No est exibindo msg");
        }

    } catch (Exception e) {
        throw (e);
    }

    driver.navigate().to(
            "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)=");

    // insere um numero de processo valido
    WebElement numero = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget"));
    numero.sendKeys("00000.000000/00");

    try {

        // clica no boto submit
        WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38"));
        submit.click();

        // espera at que o elemento que contm a msg de erro esteja visvel
        WebDriverWait wait = new WebDriverWait(driver, 30);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("Feedback_Message_Error")));

        if (!driver.findElement(By.className("Feedback_Message_Error")).isDisplayed()) {
            Assert.fail("No est exibindo msg");
        }

    } catch (Exception e) {
        throw (e);
    }
}

From source file:TestaCadastroProcesso.java

@Test(dependsOnGroups = "required", groups = "salva")
public void testaInsercaoProcesso() {

    driver.navigate().to(//from w  w  w  .j a  va  2s . c  o  m
            "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)=");

    driver.navigate().to(
            "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)=");

    try {

        // insere um numero de processo valido
        WebElement numero = driver
                .findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget"));
        numero.sendKeys(proc);

        // insere um tipo de processo valido
        WebElement tipo = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wttipoProcessoWidget"));
        tipo.sendKeys("a");

        // clica no boto submit
        WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38"));
        submit.click();

        // espera at que o boto de encerrar cadastro esteja visvel
        WebDriverWait wait = new WebDriverWait(driver, 60);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("corbranca")));

        if (!driver.findElement(By.className("corbranca")).isDisplayed()) {
            Assert.fail("No exibiu o boto encerrar cadastro");
        }
    } catch (Exception e) {
        throw (e);
    }
}

From source file:TestaCadastroProcesso.java

@Test(dependsOnGroups = "salva", groups = "salvou")
public void testaSeInseriuProcesso() throws Exception {

    driver.navigate()//  ww  w . j  a v  a 2s.  co  m
            .to("http://52.1.49.37/SIAPCON_SPRINT11/ListarProcessos.jsf?(Not.Licensed.For.Production)=");

    try {

        // insere orgao do processo na busca
        WebElement orgao = driver
                .findElement(By.id("RichWidgets_wt88:wtMainContent:wtnumeroProcessoOrgaoWidget"));
        orgao.sendKeys(proc.substring(0, 5));

        // insere numero do processo na busca
        WebElement numero = driver
                .findElement(By.id("RichWidgets_wt88:wtMainContent:wtnumeroProcessoNumeroWidget"));
        numero.sendKeys(proc.substring(5, 11));

        // insere ano do processo na busca
        WebElement ano = driver.findElement(By.id("RichWidgets_wt88:wtMainContent:wtnumeroProcessoAnoWidget"));
        ano.sendKeys(proc.substring(11, 13));

        // acha o input do submit e clica para fazer a pesquisa
        WebElement submit3 = driver.findElement(By.xpath("//input[@type='submit']"));
        submit3.click();

        // para esperar a resposta do Ajax impede o Selenium de prosseguir
        Thread.sleep(60000);

        WebElement table = driver.findElement(By.id("RichWidgets_wt88:wtMainContent:wtProcessoTableAjaxRfrsh"));

        WebElement a = driver.findElement(By.id("RichWidgets_wt88:wtMainContent:wtProcessoTable:0:wt7"));

        String processo = proc.substring(0, 5) + "." + proc.substring(5, 11) + "/" + proc.substring(11, 13);

        if (!a.getText().toString().contains(processo)) {
            Assert.fail("No cadastrou!");
        }

    } catch (Exception e) {
        throw (e);
    }
}