vendredi 20 avril 2018

Selenium: Clicked Element changes depending on number of instance launched

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.

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

Thanks

Aucun commentaire:

Enregistrer un commentaire