title: Python/Selenium Finding a specific class element, analyzing if it contains a specific span class, if it does, copy the link
body: <p>Trying to create a script that loops through my inbox and find all div classes that contain "relative flex", if the div class contains a span class labelled "dn dib-1" then it copies and saves the following href link to my list and moves onto the next div. </p>
  
  <p>Here is the html code: </p>
  
  <pre><code>   &lt;div class="relative flex"&gt;
        &lt;span class="dn dib-l" style="left: -16px;"&lt;/span&gt;
        &lt;a href="/conversations/269190401#newest_message" class="flex-auto mv0 f5 fw4 lh-copy light-gray truncate no-underline outline-none"&gt;hey how are you?&lt;/a&gt;
  </code></pre>
  
  <p>Here is the code I have now: </p>
  
  <pre><code>link_list = []
  sex_list = []
  message = browser.find_elements_by_xpath('//*[@class="relative flex"]')
  message_new = browser.find_elements_by_xpath('//*[@class="dn dib-l"]')
  for item in message:
              link = item.find_element_by_xpath('.//a').get_attribute('href')
              if message_new in message:
                  link_list.append(link)
  </code></pre>
  
  <p>Issue:
  message, message_new all contain data when requested, however despite there being multiple messages with these classes, link variable only contains one element and link_list contains no elements. What changes do I need to make in my code in order for it to save all links within div classes that contain this span class?</p>