NoSuchWindow error when I try to use Facebook sign in using RSelenium

101 Views Asked by At

I am trying to log in to a site that uses facebook login, using RSelenium. I can enter my email and password and click login, but then returns a "NoSuchWindow" error. Is this because the Facebook login tab automatically closes? How can I prevent this error?


rm(list = ls())

library(RSelenium)
library(keyring)
library(rvest)
library(magrittr)

# Start Selenium Session
#docker run -d -p 4445:4444 selenium/standalone-firefox
remDr <- RSelenium::remoteDriver(remoteServerAddr = "localhost",
                                 port = 4445L,
                                 browserName = "firefox")
remDr$open()

remDr$navigate("https://www.furimawatch.net/signin/")
remDr$findElement('xpath', '//*[@id="btnTermsAgree"]')$clickElement()
remDr$findElement('xpath', '//*[@id="btnFacebookSignin"]')$clickElement()
remDr$switchToWindow(setdiff(remDr$getWindowHandles(), remDr$getCurrentWindowHandle())[[1]])
remDr$findElement('xpath', '//*[@id="email"]')$sendKeysToElement(list("email"))
remDr$findElement('xpath', '//*[@id="pass"]')$sendKeysToElement(list("password"))
remDr$findElement('xpath', '//*[@id="loginbutton"]')$clickElement()
remDr$screenshot(display = TRUE)

This returns the following error:

Selenium message:Browsing context has been discarded
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: '0d8a70d5e451', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.104-linuxkit', java.version: '11.0.15'
Driver info: driver.version: unknown

Error:   Summary: NoSuchWindow
     Detail: A request to switch to a different window could not be satisfied because the window could not be found.
     class: org.openqa.selenium.NoSuchWindowException
     Further Details: run errorDetails method
1

There are 1 best solutions below

2
On

You are facing NoSuchWindow error as the Browsing context has been discarded which is due to the incompatibility between the versions of the binary executables (WebDriver & Browser).

This symptom is reflected as in:

Driver info: driver.version: unknown

which implies the webdriver version can't be recognized due to incompatibility.

Following the compatibility matrix will address the issue.