Search
Display results as :
Advanced Search
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
Arahant
Active particpant
Active particpant
Posts : 23
Join date : 2012-02-29

I'm facing issue with dropdown elements selection in webdriver. Empty I'm facing issue with dropdown elements selection in webdriver.

on Thu Mar 01, 2012 6:57 pm
Hi,

Anybody help me out.

I am trying to select each elements one by one from drop down list. But unable to achieve the needed.My code is as below.

WebElement box = driver.findElement(By.xpath(ORproperties.quiecklnk));
List names = box.findElements(By.tagName("option"));
Select select = new Select(driver.findElement(By
.xpath(ORproperties.quiecklnk)));
Thread.sleep(5000L);
select.selectByIndex(1);
select.selectByIndex(2); Here if i try to select 2nd index (iteration)throwing error as Element not found in the cache - perhaps the page has changed since it was looked up

Anybody any ideas are most welcome Smile
avatar
zlos7ar
Amateur
Amateur
Posts : 41
Join date : 2012-01-13
Age : 31
Location : Germany

I'm facing issue with dropdown elements selection in webdriver. Empty Re: I'm facing issue with dropdown elements selection in webdriver.

on Thu Mar 01, 2012 11:28 pm
And how does the menu work exactly ? I mean the dropdown shows when you click it or when you put your mouse over it ? And what browser are you using ?

maybe use something like this in the first case: selenium.select("xpath", "specific menu text");

or in second case use : selenium.mouseOver("xpath"); and then selenium.click("xpath to the menu item");
avatar
Arahant
Active particpant
Active particpant
Posts : 23
Join date : 2012-02-29

I'm facing issue with dropdown elements selection in webdriver. Empty Re: I'm facing issue with dropdown elements selection in webdriver.

on Mon Mar 05, 2012 1:29 pm
Thanks for your reply,

I have drop down in xpath as follows (Click type drop down)





















If you click on it.
Shows drop down list, but if you try to select the item from drop down, x path is not appearing to select them .Only x path is appearing for main drop down ).

And i'm using Firefox 10.0.2 V.
avatar
zlos7ar
Amateur
Amateur
Posts : 41
Join date : 2012-01-13
Age : 31
Location : Germany

I'm facing issue with dropdown elements selection in webdriver. Empty Re: I'm facing issue with dropdown elements selection in webdriver.

on Mon Mar 05, 2012 3:19 pm
you do not need to use xpath for the dropdown elements you need it only for the box

selenium.select("xpath of the main drop down", "here you put the name(text - home,cms,menu list and so on...) of the item you want to select");

so in your case if you want to select for example Dashboard the command is:

selenium.select("xpath for main drop down", "Dashboard"); and make sure you write it like you see it in the drop down (small/capital letters)
avatar
Arahant
Active particpant
Active particpant
Posts : 23
Join date : 2012-02-29

I'm facing issue with dropdown elements selection in webdriver. Empty Re: I'm facing issue with dropdown elements selection in webdriver.

on Mon Mar 05, 2012 5:25 pm
Dear thanks for your view.

I tried with this code

Select select = new Select(driver.findElement(By
.xpath(ORproperties.quiecklnk)));
select.selectByIndex(2);


Working fine but only specific index of drop down item i can select in above code i,e index 2 (CMS). Now i'm looking to implement in for loop so that i can check all item in drop down one by one.If any idea about same please post snippet.
avatar
zlos7ar
Amateur
Amateur
Posts : 41
Join date : 2012-01-13
Age : 31
Location : Germany

I'm facing issue with dropdown elements selection in webdriver. Empty Re: I'm facing issue with dropdown elements selection in webdriver.

on Mon Mar 05, 2012 5:30 pm
try smth like this

int i=1;
for (i<=x) {

Select select = new Select(driver.findElement(By.xpath(ORproperties.quiecklnk)));
select.selectByIndex(i);
i++;
}

where x is the number of items in the drop down

avatar
Arahant
Active particpant
Active particpant
Posts : 23
Join date : 2012-02-29

I'm facing issue with dropdown elements selection in webdriver. Empty Re: I'm facing issue with dropdown elements selection in webdriver.

on Mon Mar 05, 2012 6:56 pm
Thanks
Sponsored content

I'm facing issue with dropdown elements selection in webdriver. Empty Re: I'm facing issue with dropdown elements selection in webdriver.

Back to top
Permissions in this forum:
You cannot reply to topics in this forum