2

So I'm just trying to get the value of a input textbox after clicking a radiobutton related to it. I have 3 radiobuttons, let's call them "radio1" "radio2" and "radio3"

By default, "radio3" is checked, my goal is to click "radio1" and then get the value of the textbox. Here is the code I'm running:

WebElement radioMonthly = driver.findElement(By.xpath("//* 
[@id=\"dateFromTo_date_format_2\"]"));

Actions actions = new Actions(driver);
actions.moveToElement(radioMonthly).click().perform();

At first attempt, "radio1" is clicked and the value stored properly, but if I launch the test again, it's "radio2" the clicked one. Note that they don't share id.

I already fixed the issue but I would like to know what's going on here

Thanks

SeekanDestroy
  • 511
  • 1
  • 5
  • 12

1 Answers1

0

Here is how I fixed it, following this thread on SO

Debugging "Element is not clickable at point" error

And the code:

WebElement radioMonthly = 
driver.findElement(By.xpath("//[@id=\"dateFromTo_date_format_2\"]"));
JavascriptExecutor clickradioMonthly = (JavascriptExecutor)driver;
clickradioMonthly.executeScript("arguments[0].click()", radioMonthly);

But still will be great if someone is able to understand and explain whats going on the question

Thanks

SeekanDestroy
  • 511
  • 1
  • 5
  • 12