title: Selenium find_element_by_css_selector not finding element
body: <p>I'm working on a personal project to automate the joining of a Twitch channel through Selenium using Python.  This is my first time using Selenium and I've run into an issue that I can't seem to resolve.</p>
  <p>When joining a channel that is flagged as containing mature content, it requires a user to click a button to start watching the stream.  My program works great until the button needs to be clicked.</p>
  <p>The HTML for button appears as:</p>
  <pre><code>&lt;button class=&quot;ScCoreButton-sc-1qn4ixc-0 ScCoreButtonPrimary-sc-1qn4ixc-1 jnsGXs ksFrFH&quot; data-a-target=&quot;player-overlay-mature-accept&quot;&gt;&lt;div class=&quot;ScCoreButtonLabel-sc-lh1yxp-0 evtFDZ&quot;&gt;&lt;div data-a-target=&quot;tw-core-button-label-text&quot; class=&quot;Layout-sc-nxg1ff-0 eZactg&quot;&gt;Start Watching&lt;/div&gt;&lt;/div&gt;&lt;/button&gt;
  </code></pre>
  <p>Since the class name appear to be dynamically generated, I planned on the using the &quot;data-a-target&quot; as the selector.  Looking at Selenium's docs, it appeared that the find_element_by_css_selector function is what I need to use.  I played around in the Chrome developer tools and was about to select the button using: <code>document.querySelector('button[data-a-target=&quot;player-overlay-mature-accept&quot;]')</code>, so I was confident that it would work with Selenium.</p>
  <p>I made the selection in my code with Selenium using the following code:</p>
  <pre><code>mature = driver.find_element_by_css_selector('button[data-a-target=&quot;player-overlay-mature-accept&quot;]')
  </code></pre>
  <p>Unfortunately, Selenium doesn't seem to be able to find it and returns the error message:</p>
  <pre><code>Message: no such element: Unable to locate element: {&quot;method&quot;:&quot;css selector&quot;,&quot;selector&quot;:&quot;button[data-a-target=&quot;player-overlay-mature-accept&quot;]&quot;}
    (Session info: chrome=97.0.4692.71)
  </code></pre>
  <p>Am I doing something blatantly wrong?  I've spent a good amount of time trying different things but nothing seems to work.</p>