vendredi 3 décembre 2021

RSelenium page load issue

Take a look at the attached piece of code. I'm trying to log in to a website with RSelenium and avoid using Sys.sleep() to wait until a page is loaded and I'm logged in.

However, using remDr$setTimeout(type = 'page load', milliseconds = 30000) doesn't wait until a page is loaded and the script goes to the next line and doesn't find the needed web element, which is located on the page after the 'log-in' page. It seems like a web driver thinks that the page is loaded when in fact it's not. No idea how to tackle the problem. Would appreciate any advice.

Unfortunately can't provide you with the website itself since it's a piece of confidential company information.

remDr$navigate("https://someWebsite") # any arbitrary chosen report to trigger login page
remDr$setTimeout(type = 'page load', milliseconds = 10000)
# web element login
we_login <- remDr$findElement(
  using = "xpath", 
  value = "/html/body/div[2]/div/div[2]/form/div[1]/input[2]"
)
remDr$setTimeout(type = 'implicit', milliseconds = 10000)
# type login
we_login$sendKeysToElement(list(CREDENTIAL_LABEL))
remDr$setTimeout(type = 'implicit', milliseconds = 10000)

# web element password
we_pw <- remDr$findElement(
  using = "xpath", 
  value = "/html/body/div[2]/div/div[2]/form/div[2]/input[3]"
)
remDr$setTimeout(type = 'implicit', milliseconds = 10000)

# type password
we_pw$sendKeysToElement(list(keyringr::decrypt_dpapi_pw(credential_path), key = "enter"))

remDr$setTimeout(type = 'page load', milliseconds = 30000)

Aucun commentaire:

Enregistrer un commentaire