Could not able to make selection in second drop down list using python and selemium
<p>I am trying to make selection on the second drop down list after making a selection on first drop down list</p>

<p>The html code used for the first is :</p>

<p><a href="http://i.stack.imgur.com/Su6qC.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/Su6qC.jpg" alt="First Drop down and its option values"></a></p>

<p>For the second drop down the html code used is :</p>

<p><a href="http://i.stack.imgur.com/eO4YO.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/eO4YO.jpg" alt="Second Drop down and its option values"></a></p>

<p>The html code for the drop down has 3 attributes namely : <code>id</code>, <code>style</code> and <code>class</code>. I want to make selection on second drop down as <code>INDIA</code>.The problem is I cant use id attribute as it is dynamic and always changes whenever i load the page and i cant be able to use class as both the drop down has same class as <code>StyledDropDown</code>.</p>

<p>I have used find element/elements by class and xpath but it is doing selection on the first drop down in first case and giving error in latter.</p>

<p>Thanks in advance  </p>

<p>You can use <code>indexing</code> here to locate desire <code>dropdown</code>, if there is no possibility to locate using any <code>attribute</code> value of these <code>dropdown</code> as below :-</p>

<pre><code>dropdown = driver.find_elements_by_class_name("StyledDropDown")

#now check first if length is equal to 2
if len(dropdown) == 2 :
 firstDropdown = dropdown[0]
 secondDropdown = dropdown[1]

 #now do your stuff with desire dropdown
</code></pre>

<p>Or you can also locate these <code>dropdown</code> using <code>xpath</code> with index to desire as below :-</p>

<pre><code>#for first drop down
firstDropdown = driver.find_element_by_xpath("(.//select[@class = 'StyledDropDown'])[1]")
</code></pre>

<p>Blockquote</p>

<pre><code>#for second drop down
secondDropdown = driver.find_element_by_xpath("(.//select[@class = 'StyledDropDown'])[2]")
</code></pre>

python selenium