title: Correctly selecting a web element through xpath with Python and Selenium
body: <p>I am triying to do scraping in a web with this structure.</p>
  
  <pre><code>&lt;div&gt;
      &lt;div class = “class1” &gt;
      &lt;div class = “class2” &gt;
      &lt;div class = “class3” &gt;
      &lt;div style = “clear: both; ” &gt;
  &lt;/div&gt;
  &lt;div&gt;
      &lt;div class = “class1” &gt;
      &lt;div class = “class2” &gt;
      &lt;div class = “class3” &gt;
      &lt;div style = “clear: both; ” &gt;
  &lt;/div&gt;    
  &lt;div&gt;
      &lt;div class = “class1” &gt;
      &lt;div class = “class2” &gt;
      &lt;div class = “class3” &gt;
      &lt;div style = “clear: both; ” &gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>in each section there is diferent information. I want to search a specific word in the class1´s and if this word exist there then I print the information. After of this I have problems. After I want to get the information in class 3 of this section. For example, if my class1 in the first section has "this word" then I Want to get the class3 information in this section.</p>
  
  <p>My code is this:</p>
  
  <pre><code>cs1 = driver.find_elements_by_class_name("class1")
  for i in cs1:
      information = i.text
      if "this word" in information:
          print(information)
          infclass3 = i.find_element_by_xpath('//following-sibling::div[@class = "class3"]')
          print(infclass3.text)
  </code></pre>
  
  <p>The problem is this: I get the class1 information with "this word", but the information about the class3 in this section I dont. Always it print the class3 in the first section, every time. for example if "this word" is in the second and third section I get something like this:</p>
  
  <pre><code>information of class1 - Section 2
  information of class3 - Section 1
  information of class1 - Section 3
  information of class3 - Section 1
  </code></pre>
  
  <p>then the information in the line 1 and 3 is right. But in the line 2 and 4 is not, 1. Because is repeat 2. Because in the section 1 is not "this word"</p>
  
  <p>Thanks for the help.</p>
  
  <p>I Hope you have a nice day :)</p>