title: How to check if an object is visible in a webpage by using its xpath?
body: <p>I'm using the RSelenium package in R to do webscraping. Sometimes after loading a webpage, it's required to check if an object is visible in a webpage or not. For example:</p>
  
  <pre><code>library(RSelenium)
  
  #open a browser
  RSelenium::startServer()
  remDr &lt;- remoteDriver$new()
  remDr &lt;- remoteDriver(remoteServerAddr = "localhost" 
                    , port = 4444
                    , browserName = "firefox")
  remDr$open()
  
  remDr$navigate("https://www.google.com")
  #xpath for Google logo
  x_path="/html/body/div/div[5]/span/center/div[1]/img"
  </code></pre>
  
  <p>I need to do something like this:</p>
  
  <pre><code>if (exist(remDr$findElement(using='xpath',x_path))){
  print("Logo Exists")
  }
  </code></pre>
  
  <p>My question is what function should I use for "exist"? The above code does not work it's just a pseudo code.
  I have also found a code which works for checking objects using their "id", here it is:</p>
  
  <pre><code>remDr$executeScript("return document.getElementById('hplogo').hidden;", args = list())
  </code></pre>
  
  <p>The above code works for only "id", how should I do the same using "xpath"?
  Thanks</p>