title: How to check if an element is present in the webpage using RSelenium?
body: <p>I have been trying to get property listings data from a website where sometimes there is a 'View More' button to load more results and sometimes it is not there. In the first case, I have been using the following code and it works fine. For example,</p>
  
  <pre><code>  url&lt;- "http://www.magicbricks.com/property-for-rent/residential-real-estate?bedroom=2&amp;proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment,Service-Apartment,Residential-House,Villa&amp;cityName=Navi-Mumbai&amp;Locality=Vashi"
    remDr$navigate(url)
    Sys.sleep(3)
    webElem &lt;- remDr$findElement("css", "#viewMoreButton a")
    while(webElem$isElementDisplayed()[[1]]){
      tryCatch({
        Sys.sleep(1)
        webElem &lt;- remDr$findElement("css", "#viewMoreButton a")
        webElem$clickElement()
      }, error=function(e){})
    }
    mb&lt;- read_html(remDr$getPageSource()[[1]])
  </code></pre>
  
  <p>But in the second case, it doesn't work. For example:</p>
  
  <pre><code>  url&lt;- "http://www.magicbricks.com/property-for-rent/residential-real-estate?bedroom=4&amp;proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment,Service-Apartment,Residential-House,Villa&amp;cityName=Navi-Mumbai&amp;Locality=Vashi"
    remDr$navigate(url)
    Sys.sleep(3)
    webElem &lt;- remDr$findElement("css", "#viewMoreButton a")
    while(webElem$isElementDisplayed()[[1]]){
      tryCatch({
        Sys.sleep(1)
        webElem &lt;- remDr$findElement("css", "#viewMoreButton a")
        webElem$clickElement()
      }, error=function(e){})
    }
    mb&lt;- read_html(remDr$getPageSource()[[1]])
  </code></pre>
  
  <p>This code gets stuck at the line 'WebElem&lt;- renDr$findElement()' and doesn't move forward or throw error.</p>
  
  <p>What am I doing wrong? </p>