title: How to find an element with respect to another element through selenium and python
body: <pre><code>&lt;div class="block-inner"&gt;
      &lt;div class="form-group"&gt;
          &lt;label&gt;Username&lt;/label&gt;
          &lt;input type="text" name="username" class="required form-control" value="" placeholder="Enter your username..."&gt;
      &lt;/div&gt;
      &lt;div class="form-group w_margin"&gt;
          &lt;label&gt;Password&lt;/label&gt;
          &lt;input name="password" type="password" class="required form-control" style="" placeholder="Enter your password..."&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <h1>Context</h1>
  
  <p>My need is to find Username in Web page and automatically has to move to the next element to fill value, and once it finds Password text and has to move to next element to fill password from dictionary. Please help me on this.</p>
  
  <pre><code>driver = webdriver.Chrome()
  driver.get("https://account.genndi.com/login")
  element = "//label[contains(text(),'')]" #xpath
  
  dictCredentials = {'Username':'abcdef', 'Password':'123'}
  for clas in driver.find_elements_by_xpath(element):
      text = clas.text
      if text in dictCredentials.keys():
          inputbox = #please help here get corresponding input element
          inputbox.send_keys(dictCredentials[text])
  </code></pre>
  
  <p>I know how to send keys directly into text box and it is easy too. But I wish to understand how to do the same operation indirectly with another class element.</p>