I have a dropdown menu with 7 values and these 7 values are stored in the form of list items under unordered list as:
<ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;">
<li class="rcbItem ">--Select--</li>
<li class="rcbHovered ">PIPL-C1-BH-RILJM</li>
<li class="rcbItem ">PIPL-C1-BH1-RILJM</li>
<li class="rcbItem ">PIPL-C1-BH2-RILJM</li>
<li class="rcbItem ">PIPL-C1-BH-RPLJM</li>
<li class="rcbItem ">PIPL-C1-DHJ-RPLJM</li>
<li class="rcbItem ">PIPL-C1-DHJ-RILJM</li>
</ul>
I want to click on each value of this dropdown menu using for loop with the help of selenium chromedriver in python.
Suppose I want to click on 2nd value PIPL-C1-BH-RILJM, I can do it as :
driver.find_element(By.XPATH,"//div[@id='ContentPlaceHolder1_rcmbCapacityTranch_DropDown']/div/ul/li[2]").click()
But to use it in the for loop, I have to do indexing on li tag. So, when I write as:
i=2
driver.find_element(By.XPATH,"//div[@id='ContentPlaceHolder1_rcmbCapacityTranch_DropDown']/div/ul/li['+str(i)+']").click()
It shows only --Select-- and does not select the 2nd value and same happens with other values of i.
I have also tried as:
i=2
driver.find_element(By.XPATH,"//div[@id='ContentPlaceHolder1_rcmbCapacityTranch_DropDown']/div/ul/li['"+str(i)+"']").click()
But --Select-- is selected again from the dropdown menu.
So, can anyone please help me to click on a particular value with indexing on li tag.
Any help would be appreciated.