I am using rselenium to automate page navigation in Firefox. My rscript imports a data frame for different conditions and creates a custom function which is then called using the apply command. In the function, each column is referenced through something like this:
#create the function
example <- function(dat) {
webElem$sendKeysToElement(list(dat[[column1]]))
#Enters text from the column in the web driver
}
apply(df, 1, example) #Should repeat the function for each row of the data
I have multiple columns that I'm referencing in the apply function so that the data from each one can have a different interaction for the web driver - for example, dat[[column2]], dat[[column3]], and so on. Mostly I'm just sending keys (tabs and arrow keys after findElement(using = 'tag name', 'body') or clicking a button that I find with the findElement function and its id.
I have the script executing and it works fine the first time through, but when it starts over I am getting errors. I would like selenium to open the starting url again, and repeat the navigation using the next line of the data frame. But, what happens is r locks up or reports an error:
Error: Summary: NoSuchDriver
Detail: A session is either terminated or not started
class: org.openqa.selenium.NoSuchSessionException
Further Details: run errorDetails method
I think that it traces back to the findElements calls in the beginning of the function or the sendKeysToElement call. I have tried closing, quitting, and re-initializing the remote driver but it doesn't seem to make a difference. Are there any tips for troubleshooting? Or a good way to do repeated navigation with selenium in r?