Chetan_K Chetan_K - 4 months ago 14
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

Select
tag and it has
div
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

try below

driver.findElement(By.cssSelector("div.loginwrap > div.selectWrapper > div.selectedvalue")).click();
driver.findElement(By.id("prepaidcard")).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

Comments