- ArahantActive particpant
- Posts : 23
Join date : 2012-02-29
I'm facing issue with dropdown elements selection in webdriver.
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
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
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
- zlos7arAmateur
- Posts : 41
Join date : 2012-01-13
Age : 36
Location : Germany
Re: I'm facing issue with dropdown elements selection in webdriver.
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");
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");
- ArahantActive particpant
- Posts : 23
Join date : 2012-02-29
Re: I'm facing issue with dropdown elements selection in webdriver.
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.
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.
- zlos7arAmateur
- Posts : 41
Join date : 2012-01-13
Age : 36
Location : Germany
Re: I'm facing issue with dropdown elements selection in webdriver.
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)
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)
- ArahantActive particpant
- Posts : 23
Join date : 2012-02-29
Re: I'm facing issue with dropdown elements selection in webdriver.
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.
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.
- zlos7arAmateur
- Posts : 41
Join date : 2012-01-13
Age : 36
Location : Germany
Re: I'm facing issue with dropdown elements selection in webdriver.
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
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
- ArahantActive particpant
- Posts : 23
Join date : 2012-02-29
Re: I'm facing issue with dropdown elements selection in webdriver.
Mon Mar 05, 2012 6:56 pm
Thanks
- Webdriver code for dropdown selection is not working
- I downloaded and installed Selenium WebDriver Jar files in my Eclipse, but still i am facing issues and couldn't run the webdriver scripsts.
- How to find Fonts of all Web Elements in selenium webdriver
- Drag and drop of html 4 elements not working using selenium webdriver?
- How to scroll up the invisible webpage to find out the elements using selenium webdriver?
Permissions in this forum:
You cannot reply to topics in this forum