简体   繁体   中英

Issue entering ESPN login info with RSelenium

I'm trying to enter text into a pop-up window through Selenium in R and can't seem to find where to do it.

library(RSelenium)

rD <- rsDriver(browser="firefox", port=4545L, verbose=F)
remDr[["client]]

remDr$navigate("http://www.espn.com/login")

The next step has really confused me. Basically, when I try to use remDr$findElements(using = "xpath", value = "...") I've had no luck. I've tried copying the xpath from the developer tools when inspecting the page but get the following:

un_enter <- remDr$findElement(using = "xpath", "/html/body/div[1]/div/div/section/section/form/section/div[1]/div/label/span[2]/input")

Selenium message:Unable to locate element: /html/body/div[1]/div/div/section/section/form/section/div[1]/div/label/span[2]/input
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: '2019-07-01T21:30:10'
System info: host: 'LAPTOP-06J6R94A', ip: '192.168.1.167', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_341'
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

Could this be because this info is in a pop-up window?

I've figured this out on my own actually. I was not calling the correct iframe: This was resolved with the following:

webElem <- remDr$findElement("css", "iframe")
remDr$switchToFrame(webElem[[1]])

# code normally from here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM