使用R和RSelenium从Web的弹出窗口中选择一个选项

时间:2019-07-10 15:30:39

标签: r rselenium

我想在网页中自动填写表格。我正在使用RSelenium,可以填写所有表格,但要填写“首选语言”字段。

该网页为:https://ontrack.sgs.com/es-ES/registration-form/

我试图找到要单击的按钮,然后弹出弹出窗口进行选择,但是我无法做到这一点。

我已经尝试了这种组合以及更多其他组合,但似乎无济于事:

library(RSelenium)

#browser parameters

rD <- rsDriver(port=4571L, browser = "chrome", chromever = "75.0.3770.90") # runs a chrome browser, wait for necessary files to download
remDrv <- rD$client
remDrv$open(silent = TRUE)
url<-paste("https://ontrack.sgs.com/es-ES/registration-form/",sep="")

#### Updating form

webElem <- remDr$findElement(using = 'class', "button")
webElem <- remDrv$findElement(using = "xpath", "//input[@class='button']")
# webElem <- remDr$findElement(using = 'css selector', ".launchentitylookup")
# webElem$clickElement()

webElem <- remDrv$findElement(using = "xpath", "//input[@name = 'ctl00$ctl00$ContentContainer$MainContent$EntityControls$EntityFormControl$EntityFormControl_EntityFormView$sgs_portallanguage_name' ]") 
webElem$sendKeysToElement(list("Español"))
webElem <- remDrv$findElement(using = "xpath", "//input[@name = 'ctl00$ctl00$ContentContainer$MainContent$EntityControls$EntityFormControl$EntityFormControl_EntityFormView$sgs_portallanguage' ]") 
webElem$sendKeysToElement(list("Español"))
webElem <- remDrv$findElement(using = "xpath", "//input[@name = 'ctl00$ctl00$ContentContainer$MainContent$EntityControls$EntityFormControl$EntityFormControl_EntityFormView$sgs_portallanguage_entityname' ]") 
webElem$sendKeysToElement(list("Español"))

我希望能够以西班牙语的形式选择一种语言。

0 个答案:

没有答案