Error selenium (rich:calendar)

0 votes

I’m not able to click element in a component. Even using JavaScriptExecutor, the click is still not possible.

public static void selecionarDataCalendario(By by,WebDriver driver,WebDriverWait wait, WebElement webElement) throws Throwable {

    Calendar dat = Calendar.getInstance();

    dat.setTime(new Date());

    SimpleDateFormat formatterMes = new SimpleDateFormat("MM");

    SimpleDateFormat formatterAno = new SimpleDateFormat("YYYY");

    SimpleDateFormat formatterDia = new SimpleDateFormat("dd");

    String mes = formatterMes.format(dat.getTime());

    String ano = formatterAno.format(dat.getTime());

    String dia = formatterDia.format(dat.getTime());

     driver.findElement(by).click();

    Thread.sleep(500);

    driver.findElement(By.xpath("//td[text()='"+ dia +"']")).click();

    Thread.sleep(500);

}
May 24, 2018 in Selenium by Martin
• 4,340 points
89 views

1 answer to this question.

0 votes

See below code:

public static void selecionarDataCalendario(By by,WebDriver driver,WebDriverWait wait, WebElement webElement) throws Throwable {

    Calendar dat = Calendar.getInstance();

    dat.setTime(new Date());

    SimpleDateFormat formatterMes = new SimpleDateFormat("MM");

    SimpleDateFormat formatterAno = new SimpleDateFormat("YYYY");

    SimpleDateFormat formatterDia = new SimpleDateFormat("dd");

    String mes = formatterMes.format(dat.getTime());

    String ano = formatterAno.format(dat.getTime());

    String dia = formatterDia.format(dat.getTime());

    driver.findElement(by).click();

    Thread.sleep(500);

    ArrayList<WebElement> elementos = (ArrayList<WebElement>) driver.findElements(By.xpath("//table[@id='SalvarForm:dataefeito']/tbody/tr/td[text()='"+ dia +"']"));

    for (WebElement elemento: elementos) {

        elemento.click();

    }

    Thread.sleep(500);

}

answered May 24, 2018 by Samarpit
• 5,890 points

Related Questions In Selenium

–1 vote
1 answer

Selenium XPath error:- Element not found

The reason for Element not found exception ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,520 points
9,629 views
0 votes
1 answer

Error with Selenium File Upload

In your code, you have used "WebElement" ...READ MORE

answered Mar 29, 2018 in Selenium by nsv999
• 5,520 points
2,479 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
3,775 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,761 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,735 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,099 views
0 votes
1 answer
0 votes
2 answers

Selenium Webdriver Error: org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'

Facing Error Exception in thread "main" org.openqa.selenium .WebDriverException: unknown ...READ MORE

answered Mar 5 in Selenium by anonymous
6,539 views