簡體   English   中英

RSelenium 中的 findElement 函數錯誤

[英]Error in findElement function in RSelenium

我正在嘗試運行此代碼:

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-SELENIUM ,然后嘗試使用該軟件包。

名稱 >5 BHK 的元素不存在。 這就是您收到錯誤的原因。 但 webElem2 與 webElem1 相同(如果有效)。

因此,要回答您的問題,您必須確定錯誤發生的位置。 這個錯誤是不言自明的。 NoSuchElement

因此,webdriver 在頁面中看不到您的三個 webelements1,2,3 之一。 如果您想使用css識別元素,假設您也是 HTML 新手,我建議您使用Selector gadget使用cssxpath識別元素

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM