Nadeem Hussain
Nadeem Hussain

Reputation: 219

Error in findElement function in RSelenium

I am trying to run this code:

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")

But I keep getting the following error:

Error: Summary: NoSuchElement Detail: An element could not be located on the page using the given search parameters. class: org.openqa.selenium.NoSuchElementException Further Details: run errorDetails method

What does this mean? And how can I overcome it? I am new to R and a first time user of RSelenium so any kind of help would be much appreciated? TIA

Upvotes: 2

Views: 1424

Answers (1)

Bharath
Bharath

Reputation: 1618

Firstly, if you are new I would strongly recommend to go over the help file R-SELENIUM and then try using the package.

The element with name >5 BHK does not exist. And that is the reason you are getting an error. but the webElem2 is the same as webElem1(if this worked).

So to answer your question, you have to identify where the error occurs. and the error is pretty self-explanatory. NoSuchElement.

So one of your three webelements1,2,3 is not seen in the page by the webdriver. If you want to identify the elements using css assuming you are new to HTML too, I would suggest you to use Selector gadget to identify the element using css or xpath

Upvotes: 1

Related Questions