2

I need to scrape the website using Rselenium, but I faced the problem - the fields with login and password aren't parsed using css selector

First I set a connection with remote service and navigated to the website I'm interested in. Before working with the information needed I have to log in. I've already done similar operations on another website without any problems. Now the function findElement doesn't work wit these very elements (login and password fields), although other elements on this page are searched easily

remDr <- RSelenium::remoteDriver(remoteServerAddr = "192.168.99.100", port = 4445L)

remDr$open()

remDr$navigate("https://aisrzn.ru/login/")

remDr$getTitle()

webElem <- remDr$findElement("css", "#menu-item-7476 > a > span > span") # here everything is okay

here's the problematic element, and I see that selector looks strange:

webElem <- remDr$findElement("css", ".fieldsLayout > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > input:nth-child(1)") 

Selenium message:Unable to locate element: .fieldsLayout > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > input:nth-child(1) For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z' System info: host: '0c3a6ca7c648', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.93-boot2docker', java.version: '1.8.0_181' Driver info: driver.version: unknown

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

I just need to log in via Rselenium to continue working with the site. Now I got stacked and ask for help. My guess is that there's something wrong with the registration form - any elements incliding in this block aren't parsed. Does anybody know how to fix this problem?

P.S. There's also another website with the same information, but I gave up working with this cause the function navigate doesn't work with it:

https://rzn.mos.ru/

1

1 Answer 1

0

You should switch to single quotes for one of the strings in your problematic line. Either of these will work:

# Single quotes around the long outer string
webElem <- remDr$findElement("css", '#paneContent > form > div:nth-child(4) > table > tbody > tr:nth-child(1) > td > input[type="text"]') 

# Single quotes around the short inner string
webElem <- remDr$findElement("css", "#paneContent > form > div:nth-child(4) > table > tbody > tr:nth-child(1) > td > input[type='text']") 
Sign up to request clarification or add additional context in comments.

1 Comment

Hi! Thanks for help, but, unfortunately, neither of these options works.. Here's the error: Selenium message:Unable to locate element: #paneContent > form > div:nth-child(4) > table > tbody > tr:nth-child(1) > td > input[type='text'] 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.