Chetan_K
Chetan_K

Reputation: 57

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

Upvotes: 0

Views: 2634

Answers (2)

Pratty
Pratty

Reputation: 85

You can also try for :

driver.findElement(By.xpath("//div[contains(text(),'NetBanking')]")).click();
driver.findElement(By.xpath("//li[@id='prepaidcard']")).click();

Upvotes: 0

SamB
SamB

Reputation: 1710

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

Upvotes: 1

Related Questions