title: How can I search for a HTML element using Python? Python Web Bot Error
body: <p>I'm following a tutorial to create a bot that can perform tasks on any web page. I am using Python3 to search any random website, then using the search results (from that site) to print data. I have imported a selenium webdriver, and have ensured that it is set up correctly.</p>
  <p>The problem i'm facing is i'm trying to create a for loop that cycles through search results. This for loop is using the class name from the website i'm testing - so the bot can identify article elements. The issue is the class name is: c-entry-box--compact__title
  This is causing
  <code>SyntaxError: Cannot assign to literal</code></p>
  <p>Is there any way around this? This websites' search results doesn't have any other shorter class names or ids that are shorter, nor does it contain hyphens or underscores. I am running my code on test website 'theverge's' search results.</p>
  <p>Relevant code:</p>
  <pre><code>try:
      main = WebDriverWait(driver, 10).until(
          EC.presence_of_element_located((By.CLASS_NAME, &quot;c-entry-box--compact__body&quot;))
      )
  
      articles = main.find_element_by_class_name(&quot;c-entry-box--compact__title&quot;)
  
      for &quot;c-entry-box--compact__title&quot; in articles:
          header = articles.find_element_by_class_name(&quot;c-entry-box--compact__title&quot;)
          print(header.text)
  finally:
      driver.quit()
  </code></pre>
  <p>Any tips or ideas to point me in the right direction is greatly appreciated!</p>
  <p>Update: 11:44pm 21/8</p>
  <p>I created a variable for the class name. Now the error is</p>
  <pre><code>...line 28, in &lt;module&gt;
  for article in articles:
  TypeError: 'WebElement' object is not iterable
  </code></pre>
  <p>Update 12:12am 22/8</p>
  <p>I made the recent posters changes and tweaked some of my code. The only error i get now is to do with the use of keyboard entries, or keys. It is a <code>AttributeError: 'list' object has no attribute 'send_keys'</code> My code is</p>
  <pre><code>search_button = driver.find_elements_by_id(&quot;icon-search&quot;)
  search = driver.find_elements_by_name(&quot;q&quot;)
  search.send_keys('facebook')
  search.send_keys(Keys.RETURN)
  </code></pre>