2

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:

enter image description here

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

2 Answers 2

2

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"))
Sign up to request clarification or add additional context in comments.

Comments

1
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))

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.