Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
venkat
Posts : 3
Join date : 2012-04-10

Unable to find dynamic dropdown items Empty Unable to find dynamic dropdown items

Tue Apr 10, 2012 8:50 pm
Hi,

I am new to selenium, i got struck for a long time with finding a item in a drop down list that was bind dynamically by selecting item from another dropdown. my sample code is followed by:

selenium.Open(".../Default.aspx");
selenium.WindowMaximize();
selenium.Click("name=ddCountry");
selenium.Click("//div[@id='ddCountry_DropDown']/div/ul/li[1]");
str = selenium.GetText("//div[@id='ddCountry_DropDown']/div/ul/li[1]");
selenium.Type("name=ddCountry", strValue);
selenium.Click("name=ddCity");
selenium.Click("//div[@id='ddCity_DropDown']/div/ul/li[1]");
str = selenium.GetText("//div[@id='ddCity_DropDown']/div/ul/li[1]");
selenium.Click("id=btnRedirect");
selenium.WaitForPageToLoad("30000");

In the above code i was trying to do like after selecting an item in a country dropdown. few items were bind to city dropdown on selectionchange event fires. my problem is " selenium.Click("//div[@id='ddCity_DropDown']/div/ul/li[1]"); "
when this code executes i got error like "Element //div[@id='ddCity_DropDown']/div/ul/li[1] not found". please provide a solution for this problem thanks in advance.

regards,
Venkat
avatar
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Unable to find dynamic dropdown items Empty Re: Unable to find dynamic dropdown items

Wed Apr 11, 2012 12:24 pm
Does this operation -

selenium.Click("//div[@id='ddCity_DropDown']/div/ul/li[1]");

cause page to load? In that case you would need to use - waitForPageToLoad("timeout")
avatar
venkat
Posts : 3
Join date : 2012-04-10

Unable to find dynamic dropdown items Empty Re: Unable to find dynamic dropdown items

Wed Apr 11, 2012 1:39 pm
Hi tarun k,

Thanks for your reply. i hav added waitforpagetoload command in my script now i got an error "Timed out after 5000 ms". im unable to find solution for this problem.

My sample code:

selenium.Click("//div[@id='ddItem_DropDown']/div/ul/li[" + count + "]");
selenium.WaitForPageToLoad("5000"); //Got error in this line
selenium.Type("name=ddItem", selenium.GetText("//div[@id='ddItem_DropDown']/div/ul/li[" + count + "]"));
string strItemValue = selenium.GetText("//div[@id='ddItem_DropDown']/div/ul/li[" + count + "]");
////ChildDropDown
selenium.Click("//input[@id='ddChild_Input']");
selenium.WaitForPageToLoad("5000");
selenium.Click("//div[@id='ddChild_DropDown']/div/ul/li[1]");
string strChild = selenium.GetText("//div[@id='ddChild_DropDown']/div/ul/li[1]");

Thanks and Regards
Venkat
avatar
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Unable to find dynamic dropdown items Empty Re: Unable to find dynamic dropdown items

Wed Apr 11, 2012 3:12 pm
can you try with waitForElementPresent method?
rohit13
rohit13
Master
Master
Posts : 180
Join date : 2012-03-29
Age : 38
Location : INDIA
http://radical-qa.blogspot.in/

Unable to find dynamic dropdown items Empty Re: Unable to find dynamic dropdown items

Wed Apr 11, 2012 3:48 pm
Use below code, this will may help you

Code:
Thread.sleep(7000);
avatar
venkat
Posts : 3
Join date : 2012-04-10

Unable to find dynamic dropdown items Empty Re: Unable to find dynamic dropdown items

Wed Apr 11, 2012 4:47 pm
Hi,

Thanks for all your replies. i hav tried all your solutions but nothing provide expected solution.

Thanks and Regards
Venkat
avatar
Rajender
Posts : 1
Join date : 2012-04-11

Unable to find dynamic dropdown items Empty Re: Unable to find dynamic dropdown items

Wed Apr 11, 2012 4:49 pm
use Thread.sleep(3000); in between two drop down lists(country and city). It will stops the execution for given time and waits for the city drop down list to load
avatar
deshjoshi
Posts : 4
Join date : 2012-04-01

Unable to find dynamic dropdown items Empty Re: Unable to find dynamic dropdown items

Mon Apr 16, 2012 3:45 pm
Hi,

After clicking on the dropdown

boolean blnSelect=false;
int intSec=0;
while(blnSelect==false && intSec<120)
{
try
{
if(selenium.isElementPresent("Element ID"));
blnSelect=true;
}
catch(Exception e)
{
intSec++;
Thread.sleep(1000);
}
}

Where 'Element ID' is the element you are waiting for.

Please use this it might help.
After waiting until the element present you can your further comments.
Sponsored content

Unable to find dynamic dropdown items Empty Re: Unable to find dynamic dropdown items

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