rselenium-webdriverdplyrrselenium

The Input password field is not displaying password but not throwing error


I'm trying to automate login with Rselenium in Rstudio please see below

remote_driver <- rsDriver(browser = "firefox", 
                          geckover = "0.33.0",
                          verbose = FALSE, 
                          port = 4457L)

# Assign the remote driver object to a variable
driver <- remote_driver[["client"]]

driver$navigate("https://etopup.gloworld.com:8443/agentportal/agentportal/Application.html#")

I can easily locate the username and the userID without any error:

Sys.sleep(2)
reseller_id_input <- driver$findElement(using = 'id', "gwt-debug-Reseller_ID")
# Supply a value to the input field (e.g., "your_reseller_id")
reseller_id_input$sendKeysToElement(list("Napset"))

user_id_input <- driver$findElement(using = 'xpath', "//div[contains(text(),'User ID:')]//following::input[1]")
#Supply a value to the input field (e.g., "your_user_id")
user_id_input$sendKeysToElement(list("Yodigzy"))

The problem is the password part, when I locate the password field and send in password text, it doesn't reflect in the password field and does not show or display any error:

#Locate the Password input field
password_field <- driver$findElement(using = "id", value = "gwt-debug-Password")
password_field$sendKeysToElement(list("your-password"))

Without this password, I can't proceed to login. Is there any logic behind this or what? I really need help with this.

Thanks


Solution

  • The problem is that there are two INPUT fields on the page with the ID of "gwt-debug-Password". The first one on the page is not visible, that's why you are seeing this behavior.

    One way to get around this is to use findElements() (plural) and then get the second element. I don't know R but after some googling I think it might be something like,

    password_field <- driver$findElements(using = "id", value = "gwt-debug-Password")
    password_field[[2]]$sendKeysToElement(list("your-password"))