The Rselenium code below comes from the answer/comment to the this SO post. Sample code is there.
option <- remDr$findElement(using = 'xpath', "//select[@id='main_ddYear']/option[@value='2014']")
option$clickElement()
Note the literal '2014' near the end of the first line.
Can a variable be used in place of the literal '2014'? E.g.,
var1 = "2014"
option <- remDr$findElement(using = 'xpath', "//select[@id='main_ddYear']/option[@value= var1 ]")
I've tried just using the variable var1
.
Also tried braces {} inside and outside of single quotes (') {var1}, '{var1}', {'var1'}
, which were ideas from other posts.
Similarly, I tried using plus signs as suggested in a similar post on how to pass variables to strings in Java. E.g., + var1 +, +var+, '+var1+'
.