title: Selenium Python nested dropdowns
body: <p>So I'm trying to test a nested dropdown with Selenium Python using the conditional statements like so:
  <a href="https://i.stack.imgur.com/rh06w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rh06w.png" alt="enter image description here" /></a></p>
  <pre><code>if d_Biz == 'Marketing':
                  biz_choose = driver.find_element(&quot;xpath&quot;, &quot;//span[@id='biz']&quot;)
                  biz_choose.click()
                  time.sleep(1)
                  gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                  gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='Marketing']&quot;).click()
                  time.sleep(1)
  
                  if d_Subbiz_1 == 'GMV':
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='GMV']&quot;).click()
                      time.sleep(1)
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Subbiz_2) + &quot;']&quot;).click()
                      time.sleep(1)
  
                  elif d_Subbiz_1 == 'CLM':
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='CLM']&quot;).click()
                      time.sleep(1)
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Subbiz_2) + &quot;']&quot;).click()
                      time.sleep(1)
  
                  else:
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Subbiz_1) + &quot;']&quot;).click()
  
              elif d_Biz == 'Lzdpay':
                  biz_choose = driver.find_element(&quot;xpath&quot;, &quot;//span[@id='biz']&quot;)
                  biz_choose.click()
                  time.sleep(1)
                  gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                  gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='Lzdpay']&quot;).click()
  
                  if d_Subbiz_1 == 'Wallet':
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='Wallet']&quot;).click()
                      time.sleep(1)
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Subbiz_2) + &quot;']&quot;).click()
                      time.sleep(1)
  
                  elif d_Subbiz_1 == 'BAR':
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='BAR']&quot;).click()
                      time.sleep(1)
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Subbiz_2) + &quot;']&quot;).click()
                      time.sleep(1)
  
              else:
                  biz_choose = driver.find_element(&quot;xpath&quot;, &quot;//span[@id='biz']&quot;)
                  biz_choose.click()
                  time.sleep(1)
                  gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@data-tag='gateway-wrapper']&quot;)
                  gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Biz) + &quot;']&quot;).click()
  </code></pre>
  <p>As you can see, I'm writing it 1 by 1. It works fine but then when the data is</p>
  <pre><code>Biz: Marketing
  Sub Biz 1: Engagement
  Sub Biz 2: Engagement
  </code></pre>
  <p>or</p>
  <pre><code>Biz: Marketing
  Sub Biz 1: Branding
  Sub Biz 2: Branding
  </code></pre>
  <p>it gives an error saying :</p>
  <pre><code>Message: element click intercepted: Element &lt;span data-meta=&quot;Field&quot; id=&quot;purpose&quot; class=&quot;next-select large voucher-template-input&quot; tabindex=&quot;0&quot;&gt;...&lt;/span&gt; is not clickable at point (526, 335). Other element would receive the click: 
  &lt;li class=&quot;next-cascader-menu-item&quot;&gt;...&lt;/li&gt;
  </code></pre>
  <p>In conclusion, this code works fine if the Sub Biz 1 and Sub Biz 2 is not the same value. Any solutions? By the way, I'm new to selenium.</p>
  <p>[[edit]]
  I also tried coding like this:</p>
  <pre><code>if d_Biz is not None:
                  biz_choose = driver.find_element(&quot;xpath&quot;, &quot;//span[@id='biz']&quot;)
                  biz_choose.click()
                  time.sleep(1)
                  gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@class='next-cascader-menu-wrapper'][1]&quot;)
                  gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Biz) + &quot;']&quot;).click()
                  if d_Subbiz_1 is not None:
                      gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@class='next-cascader-menu-wrapper'][2]&quot;)
                      gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Subbiz_1) + &quot;']&quot;).click()
                      time.sleep(1)
                      if d_Subbiz_2 is not None:
                          gwrapper = driver.find_element(&quot;xpath&quot;, &quot;//div[@class='next-cascader-menu-wrapper'][3]&quot;)
                          gwrapper.find_element(&quot;xpath&quot;, &quot;//li[normalize-space()='&quot; + str(d_Subbiz_2) + &quot;']&quot;).click()
                          time.sleep(1)
  </code></pre>
  <p>With this code, it works fine for the duplicated value for d_Subbiz_1 and d_Subbiz_2 while the error shows when there are no d_Subbiz_1 or d_Subbiz_2 value</p>