title: How do I resolve the NoSuchElementException error in Selenium?
body: <p><a href="https://i.stack.imgur.com/53onI.jpg" rel="nofollow noreferrer">HTML</a>I was following an online tutorial on scraping glassdoor website via selenium.
  My code does not get through this statement:</p>
  <pre><code>    try:
          driver.find_element_by_class_name(&quot;selected&quot;).click()
          print('x out worked')
      except ElementClickInterceptedException:
          print('x out failed')
          pass
  
      time.sleep(.1)
  
      try:
          driver.find_element_by_css_selector('[alt=&quot;Close&quot;]').click()
          print(' x out worked')
      except NoSuchElementException:
          print(' x out failed (next page or missing)')
          pass
  </code></pre>
  <p>The error I receive is :</p>
  <p>NoSuchElementException: Message: no such element: Unable to locate element: {&quot;method&quot;:&quot;css selector&quot;,&quot;selector&quot;:&quot;.selected&quot;}</p>
  <p>Couple of things that I tried:</p>
  <ol>
  <li>driver.maximize_window()</li>
  <li>driver.implicitly_wait(20)</li>
  </ol>