【问题标题】:Error in findElement function in RSeleniumRSelenium 中的 findElement 函数出错
【发布时间】:2016-10-16 18:38:32
【问题描述】:

我正在尝试运行此代码:

library(RSelenium)

pJS<- phantom()

remDr <- remoteDriver(browserName = "phantomjs")

url<- "http://www.magicbricks.com/property-for-rent/residential-real-estate?proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment,Service-Apartment,Residential-House,Villa&cityName=Mumbai"

remDr$open()

remDr$navigate(url)

webElem1 <- remDr$findElement("name", ">5 BHK")

webElem2 <- remDr$findElement("css", "#refinebedrooms li:nth-child(6)")

webElem3 <- remDr$findElement("css", "#viewMoreButton a")

但我不断收到以下错误:

错误:摘要:NoSuchElement 详细信息:使用给定的搜索参数无法在页面上找到元素。 类:org.openqa.selenium.NoSuchElementException 更多细节:运行errorDetails方法

这是什么意思?我该如何克服它?我是 R 的新手,也是 RSelenium 的第一次用户,所以任何形式的帮助都将不胜感激? TIA

【问题讨论】:

    标签: r rselenium


    【解决方案1】:

    首先,如果您是新手,我强烈建议您阅读帮助文件R-SELENIUM,然后尝试使用该软件包。

    名称>5 BHK 的元素不存在。这就是您收到错误的原因。但 webElem2 与 webElem1 相同(如果可行)。

    因此,要回答您的问题,您必须确定错误发生的位置。并且错误是不言自明的。 NoSuchElement。

    因此,webdriver 在页面中看不到您的三个 webelements1、2、3 之一。如果您想使用css 识别元素,假设您也是HTML 新手,我建议您使用Selector gadget 来识别使用css 或xpath 的元素

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多