title: Clicking element inside ::before
body: <p>I am trying to use Selenium to click an element that's contained within a ::before selector, but every time I try to do so Selenium returns a <code>NoSuchElementException</code>. Looking at some related threads, it seems as though this is expected behavior for reasons I don't fully understand (see some seemingly related answers here: <a href="https://stackoverflow.com/questions/42501247/how-to-click-on-before-element">How to click on ::before element</a>; <a href="https://groups.google.com/forum/#!topic/selenium-users/ZUi9cenA13o" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/selenium-users/ZUi9cenA13o</a>). Note that this section is <em>not</em> inside an iframe, which seems to be another common issue when people run into problems like this.</p>
  
  <p>Here's the relevant section of HTML for the page I'm trying to use: </p>
  
  <pre><code>&lt;div class="container"&gt;
      ::before
    &lt;div id="ctl00_divPageContent" class="page-content center-block"&gt;
      &lt;div class="col-xs-12 main remove-padding-sm add-padding-quater-sm-remove-padding-xs add-padding-quater-xs"&gt;
        &lt;div id="ctl00_ContentPlaceHolder2_upView"&gt;
          &lt;div class="col-xs-12 remove-padding-xs"&gt;
            &lt;div class="pull-right"&gt;
              &lt;div class="modal-dropdown pull-right"&gt;
                &lt;a data-toggle="dropdown" tabindex="1"&gt;
                  &lt;i class="fa fa-ellipsis-v"&gt;
                      ::before
                  &lt;/i&gt;
                &lt;/a&gt;
                &lt;div class="dropdown-menu" role="menu"&gt;
                  &lt;a id="ctl00_ContentPlaceHolder2_lbnSelected" href="javascript:__doPostBack('ctl00$ContentPlaceHolder2$lbnSelected','')"&gt;Select&lt;/a&gt;
                  &lt;a id="ctl00_ContentPlaceHolder2_lbnPdf" href="javascript:__doPostBack('ctl00$ContentPlaceHolder2$lbnPdf','')"&gt;
                    &lt;em class="txt-underline"&gt;Print PDF&lt;/em&gt;
                  &lt;/a&gt;
  </code></pre>
  
  <p>I'm trying to click on the second javascript link within the drop-down menu (i.e., the one with <code>id="ctl00_ContentPlaceHolder2_lbnPdf"</code>), but I haven't been able to get anything to work. In the second thread listed above, others seem to show that this requires executing some JavaScript, but I'm having trouble understanding what JavaScript I actually need to run to successfully do this, or how to execute it from within Python.</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>EDIT: Here's some of the code I've tried using:</p>
  
  <pre><code># set up driver
  driver = webdriver.Chrome()
  ... # omitting code here for navigating to the right page, etc.
  # each of these returns a NoSuchElementException
  driver.find_elements_by_xpath('//*[@id="ctl00_ContentPlaceHolder2_lbnPdf"]')
  driver.find_element_by_css_selector('#ctl00_ContentPlaceHolder2_lbnPdf')
  driver.find_element_by_link_text('Print PDF Resume')
  </code></pre>
  
  <p>Note that I'm pretty sure that I have navigated to the correct page, because I'm able to locate the div at the top of the block I've pasted using its xpath: </p>
  
  <pre><code># does not return a NoSuchElementException
  driver.find_element_by_xpath('//*[@id="aspnetForm"]/div[2]/div[1]/div')
  </code></pre>