Chetan_K Chetan_K - 1 year ago 64
Java Question

To Automate a dropdown box without Select tag using Selenium

I'm trying to automate a drop down box in home page of HDFC bank in which by default 'Net banking' is selected. It does not have a

tag and it has
tag. Also I tried to click on the drop down first and select the values one by one, but I'm getting error like

Element can't be clicked

Please help me with this.

driver.findElement(By.className("selectedvalue")).click(); //Error for this statement

Answer Source

try below

driver.findElement(By.cssSelector("div.loginwrap > div.selectWrapper > div.selectedvalue")).click();

I generated this from Selenium IDE for firefox. It is a plugin for Firefox which you can record user actions and export the test case to Java ( among many other languages). This is the link Selenium IDE