Order of Actions and Select objects | Selenium Forum
M
Posted on 20/08/2016
I am using a [i:3eumad3c]Select[/i:3eumad3c] object and an [i:3eumad3c]Actions[/i:3eumad3c] object in the same code. The problem I am having is - if I use Actions object to simulate an action, then use the Select object to do some task, I am unable to use the previous Actions object to perform any tasks. It is not giving me any errors, but it is unable to perform the intended action in the last step.

For example,
[code:3eumad3c]// this works
Actions act = new Actions(driver);
act.click(driver.findElement(By.xpath("//*[@id='ddcl-selInd']/span"))).build().perform();

// this works
Select s = new Select(driver.findElement(By.id("selAge")));
s.selectByVisibleText("Within 5 days");

// this does not give any errors but it DOES NOT perform the action either
act.click(driver.findElement(By.xpath("//*[@id='ddcl-selInd-i5']"))).build().perform();[/code:3eumad3c]

However if I use Select before or after all the usage of Actions object, everything works as expected.

[code:3eumad3c]// this works
Select s = new Select(driver.findElement(By.id("selAge")));
s.selectByVisibleText("Within 5 days");

// this works
Actions act = new Actions(driver);
act.click(driver.findElement(By.xpath("//*[@id='ddcl-selInd']/span"))).build().perform();

// this works and PERFORMS the action as intended
act.click(driver.findElement(By.xpath("//*[@id='ddcl-selInd-i5']"))).build().perform();[/code:3eumad3c]

Any idea why this happens ?

M
Replied on 23/08/2016

I'm not able to understand your question?