Reputation: 3486
I am trying to click an input object on a webpage using a JS call. First, I'm using RSelenium to pull up the page:
library(RSelenium)
rD <- rsDriver(port = 4444L, verbose = FALSE)
remDr <- rD$client
remDr$navigate('https://www.tripadvisor.com/Hotel_Review-g293913-d306432-Reviews-Ambassador_Hotel_Taipei-Taipei.html')
From the page I'm trying to click on the button "All languages" from the menu below:
I was trying to trigger the click with a call to JS, which works when running the script
in the chrome console
script <- "document.getElementById('filters_detail_language_filterLang_ALL').click();"
remDr$executeScript(script, args=list())
But I get the following error:
remDr$executeScript(script, args = list())
Selenium message:unknown error: 'args' must be a list (Session info: chrome=64.0.3282.186) (Driver info: chromedriver=2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8),platform=Mac OS X 10.12.4 x86_64)
Error: Summary: UnknownError Detail: An unknown server-side error occurred while processing the command. Further Details: run errorDetails method
Upvotes: 2
Views: 1946
Reputation: 11
element = remDr$findElement(using='xpath','//*
[@id="filters_detail_language_filterLang_ALL"]')
script <-"document.getElementById('filters_detail_language_filterLang_ALL').click();"
remDr$executeScript(script, args=list(element))
Upvotes: 1
Reputation: 1804
There may be a bug in RSelenium as such.
Try passing an dummy argument in the list method .
Use this:
remDr$executeScript(script, args = list("fugazi"))
Upvotes: 2