title: Scraping Javascript in R with RSelenium
body: <p>I'm attempting to scrape the <a href="https://www.washingtonpost.com/graphics/national/police-shootings/" rel="nofollow noreferrer">Washington Post's database on police shootings</a>. Since it's not html I can't use <code>rvest</code>, so instead I used <a href="https://cran.rstudio.com/web/packages/RSelenium/" rel="nofollow noreferrer">RSelenium</a> and <a href="https://phantomjs.org" rel="nofollow noreferrer">phantomjs</a>.</p>
  
  <pre><code>library(RSelenium)
  
  checkForServer()
  startServer()
  
  eCap &lt;- list(phantomjs.binary.path = "C:/Program Files/Chrome Driver/phantomjs.exe")
  remDr &lt;- remoteDriver(browserName = "phantomjs", extraCapabilities = eCap)
  
  remDr$open()
  
  remDr$navigate("http://www.washingtonpost.com/graphics/national/police-shootings/")
  </code></pre>
  
  <p>Upon inspecting the source, it's apparent the items I'm interested in have the following <code>id</code> and <code>class</code> </p>
  
  <pre><code>&lt;div id="js-list-690" class="listWrapper cf"&gt;
  </code></pre>
  
  <p>or in Chrome:</p>
  
  <p><a href="https://i.stack.imgur.com/cQ1tb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cQ1tb.png" alt="screenshot of the relevant item&#39;s source in Chrome"></a></p>
  
  <p>I can access the text of the individual item:</p>
  
  <pre><code>remDr$findElement("css", "#js-list-691")$getElementText()
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>[[1]]
  [1] "An unidentified person, a 47-year-old Hispanic man, was shocked with a stun gun and shot on July 30, 2015, in Whittier, Calif. Los Angeles County deputies were investigating a domestic disturbance when he threatened the officers and struck one of them with a metal rod.\nMALEDEADLY WEAPONHISPANIC45 TO 54\nCBS Los AngelesWhittier Daily News"}
  </code></pre>
  
  <p>But if I want to get a list of all these items:</p>
  
  <pre><code>remDr$findElements("class name", "listWrapper cf")
  </code></pre>
  
  <p>results in an error.</p>
  
  <p>How do I</p>
  
  <ol>
  <li>Get a list of all the elements which share this <code>listWrapper cf</code> class?</li>
  <li>Return a list of the text associated with each element?</li>
  </ol>