0

When I try to run the following lines with a single command

mybrowser$navigate("http://www.decolar.com/shop/flights/results/roundtrip/BSB/VCP/2016-06-15/2016-06-19/1/0/0")
eprice <- mybrowser$findElements(using = 'css selector',"#clusters .price-amount" )

It produces the following error:

Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: org.openqa.selenium.WebDriverException

However, when I run the last line alone after the error it works just fine:

> eprice <- mybrowser$findElements(using = 'css selector',"#clusters .price-amount" )
> summary(eprice)
      Length Class      Mode
 [1,] 1      webElement S4  
 [2,] 1      webElement S4  
 [3,] 1      webElement S4  
 [4,] 1      webElement S4  
 [5,] 1      webElement S4  
 [6,] 1      webElement S4  
 [7,] 1      webElement S4  
 [8,] 1      webElement S4  
 [9,] 1      webElement S4  
[10,] 1      webElement S4

I want to run these lines inside a function so that I can get the flight prices from the site but they don’t work automatically. I’ve tried to set Sys.sleep(4) and mybrowser$setImplicitWaitTimeout(4) between them and it didn’t work.

When inside function the error trackback is as follows:

 Error:      Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: org.openqa.selenium.WebDriverException 
5 stop(errMessage, call. = FALSE) 
4 checkStatus() 
3 queryRD(paste0(serverURL, "/session/", sessionInfo$id, "/elements"), 
    "POST", qdata = toJSON(list(using = using, value = value)), 
    json = TRUE) 
2 mybrowser$findElements(using = "css selector", "#clusters .price-amount") 
1 getPrices()
  • I've had this problem before, always caused by delays in the loading of the page. Try the commands inside a for loop and check what value of `Sys.sleep` works best. On certain pages I've had to have as much as 11. – PavoDive May 04 '16 at 03:56
  • Thanks! If you’re interested, I found a way to workaround the problem by using two try blocks like follows: `try(eprice <- mybrowser$findElements(using = 'css selector',"#clusters .price-amount"), silent = T)` – Matheus Facure May 08 '16 at 02:49

0 Answers0