Rselenium is able to find different types of element inside the html page.
You can use one of these elements.
findElement( using = c("xpath", "css selector", "id", "name", "tag name",
"class name", "link text", "partial link text", "tag name", "xpath"),
value ="the code that you find in the html page")$clickElement()
class name
: Returns an element whose class name contains the search value; compound class names are not permitted.
css selector
: Returns an element matching a CSS selector.
id
: Returns an element whose ID attribute matches the search value.
name
: Returns an element whose NAME attribute matches the search value.
link text
: Returns an anchor element whose visible text matches the search value.
partial link text
: Returns an anchor element whose visible text partially matches the
search value.
tag name
: Returns an element whose tag name matches the search value.
xpath
: Returns an element matching an XPath expression.
Belwow a small example:
library(RSelenium)
rD<-rsDriver(browser = 'chrome', port = 428L, chromever = '87.0.4280.88')
remDr<-rD$client
remDr$navigate('https://migusto.migros.ch/de/rezept-uebersicht/mexiko')
remDr$findElement(using = 'xpath', value = '//*[@id="top"]/div[3]/main/div[1]/div/div[2]/form/a')$clickElement()
If you want to deep the argument here the official documentation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…