栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

RSelenium和Javascript

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

RSelenium和Javascript

您不需要在

executescript
这里使用:

require(RSelenium)checkForServer()startServer()remDr<-remoteDriver()remDr$open()remDr$getStatus()remDr$navigate("http://fyed.elections.on.ca/fyed/en/form_page_en.jsp")p.pres<-c('m1p4v4', 'n3t2y3', 'n2h3v1')webElem<-remDr$findElement(using = 'id', value = "ppre")webElem$sendKeysToElement(list(p.pres[1])) # send the first post pre to the elementremDr$findElement("id", "en_btn_arrow")$clickElement() # find the submit button and click it

如果您想使用它,

executescript
则可以将最后一行替换为:

remDr$executescript("arguments[0].click();"     , list(remDr$findElement("id", "en_btn_arrow")))

executescript
将脚本作为参数和列表。如果列表中的任何元素属于类,
webElement
则可以像DOM元素一样在脚本中引用它们。在这种情况下,第一个元素(Javascript中的零索引)是a
webElement
,我们要求在Javascript中单击它。

此外,如果您检查按钮后面的源代码,就会发现在按下按钮时它会

document.ppre.submit()
更简单地调用(在这种情况下,如果您想使用),
executescript
您可以执行以下操作:

remDr$executescript("document.ppre.submit();")


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/394605.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号