Reputation: 185
I am trying to log into website mol.medicover.pl using RSelenium with phantom. I am not able to send login and pass using sendKeysToElement command I think that problem is with forcing phantom to accept sslcerts. My code :
library(RSelenium)
my_extra <- list("--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--web-security=no")
cDrv3 <- RSelenium::rsDriver(port = 4569L, browser = "phantomjs",
extraCapabilities = my_extra)
remDr <- cDrv3[["client"]]
remDr$navigate("https://mol.medicover.pl")
log_into <- remDr$findElement(using = "xpath", "//*[@id=\"oidc-submit\"]")
log_into$clickElement()
windows_list <- remDr$getWindowHandles()
remDr$closeWindow()
remDr$switchToWindow(windows_list[[2]])
card_number <- remDr$findElement(using = "xpath", "//*[@id=\"username-email\"]")
card_number$sendKeysToElement(list("test", key = "enter"))
After the last code line I get an error:
Selenium message:TypeError - undefined is not a function
(evaluating _getTagName(currWindow).toLowerCase()')
Command duration or timeout: 9 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'kacper-Lenovo-ideapad-Y700-15ISK', ip: '127.0.1.1',
os.name: 'Linux', os.arch: 'amd64',os.version: '4.8.0-58
generic',java.version: '1.8.0_131'
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false,
handlesAlerts=false, databaseEnabled=false, version=2.1.1, platform=LINUX,
browserConnectionEnabled=false, proxy=Proxy(direct), nativeEvents=true,
acceptSslCerts=false, driverVersion=1.2.0, locationContextEnabled=false,
webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true,
driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: c0a7edf0-6fc9-11e7-ba6e-a34a400bb453
Error: Summary: UnknownCommand
Detail: The requested resource could not be found, or a request was
received using an HTTP method that is not supported by the mapped resource.
class: org.openqa.selenium.UnsupportedCommandException
Further Details: run errorDetails method
I tried using wdman package to start Rselenium but I stack with same problem
cDrv <- phantomjs(extras = "--ignore-ssl-errors=true --ssl-protocol=any
--web-security=no", port =4565L, version = "1.9.8")
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4565,
browserName = "phantomjs")
remDr$open()
All time I am starting my session I get $acceptSslCerts = FALSE. I have no idea how to force phantomjs to change it.
[1] "Connecting to remote server"
$browserName
[1] "phantomjs"
$version
[1] "2.1.1"
$driverName
[1] "ghostdriver"
$driverVersion
[1] "1.2.0"
$platform
[1] "linux-unknown-64bit"
$javascriptEnabled
[1] TRUE
$takesScreenshot
[1] TRUE
$handlesAlerts
[1] FALSE
$databaseEnabled
[1] FALSE
$locationContextEnabled
[1] FALSE
$applicationCacheEnabled
[1] FALSE
$browserConnectionEnabled
[1] FALSE
$cssSelectorsEnabled
[1] TRUE
$webStorageEnabled
[1] FALSE
$rotatable
[1] FALSE
$acceptSslCerts
[1] FALSE
$nativeEvents
[1] TRUE
$proxy
proxy$proxyType
[1] "direct"
$id
[1] "8166b460-6fcd-11e7-bac0-1f0af3c89c32"
Upvotes: 2
Views: 648
Reputation: 30435
This is a known issue see https://github.com/ariya/phantomjs/issues/14211
As a workaround you can use a more uptodate version of ghostdriver then that packaged with phantomjs. Goto to https://github.com/detro/ghostdriver/releases I downloaded ghostdriver version 2.1.0. You can reference the path to this updated ghostdriver as an extraCapability:
library(RSelenium)
my_extra <- list(phantomjs.ghostdriver.path = "/home/john/ghostdriver-2.1.0/src/main.js")
cDrv3 <- RSelenium::rsDriver(port = 4569L, browser = "phantomjs",
extraCapabilities = my_extra)
remDr <- cDrv3[["client"]]
remDr$navigate("https://mol.medicover.pl")
log_into <- remDr$findElement(using = "xpath", "//*[@id=\"oidc-submit\"]")
log_into$clickElement()
windows_list <- remDr$getWindowHandles()
remDr$closeWindow()
remDr$switchToWindow(windows_list[[2]])
card_number <- remDr$findElement(using = "xpath", "//*[@id=\"username-email\"]")
card_number$sendKeysToElement(list("test", key = "enter"))
card_number$screenshot(display = TRUE)
#clean up
remDr$close()
cDrv3$server$stop()
Upvotes: 3