0

I use Rselenium and I use javascript queries.

The query in javascript is this:

document.querySelectorAll('ul#test div.mytext')[1].innerText.split('\n').filter(x => x).join('???')

When I try to run it in RSelenium code I use this:

remDr$executeScript('return document.querySelectorAll(\'ul#test div.mytext\')[ 1 ].innerText.split(\'//\n\').filter(x => x).join(\'???\')', args = list("dummy"))

However I receive an error and I belive it is due to \n character

How can I write it properly?

Pozmanski
  • 181
  • 11

1 Answers1

0

You are using single quotes for delimiting the code you want to run when it also contains single quotes. Since there are no double quotes in the expression, try:

remDr$executeScript("return document.querySelectorAll(\'ul#test div.mytext\')[ 1 ].innerText.split(\'//\n\').filter(x => x).join(\'???\')", args = list("dummy"))
R. Schifini
  • 9,085
  • 2
  • 26
  • 32