RSelenium icon indicating copy to clipboard operation
RSelenium copied to clipboard

Move to new pop-up window using Rselenium

Open MislavSag opened this issue 7 years ago • 1 comments

I have following Rselenum code:

library(RSelenium)

remDr <- remoteDriver(remoteServerAddr = "192.168.99.100", port = 4445L, browserName = "chrome")
remDr$open()

# Simulate browser session and fill out form
remDr$navigate("https://oss.uredjenazemlja.hr/public/lrServices.jsp?action=publicLdbExtract")

remDr$findElement(using = "xpath", 
                  "//*[@id='x-auto-29']/input")$sendKeysToElement(list("Beli Manastir", key = "enter"))
Sys.sleep(1L)
remDr$findElement(using = "xpath", 
                  "//*[@id='x-auto-30']/input")$clickElement()
Sys.sleep(1L)
remDr$findElement(using = "xpath", 
                  "//*[@id='x-auto-30']/input")$sendKeysToElement(list("Baranjsko", key = "enter"))
Sys.sleep(1L)
remDr$findElement(using = "id", 
                  "x-auto-32")$sendKeysToElement(list("1"))
Sys.sleep(1L)
remDr$findElement(using = "xpath", 
                  "//*[@id='x-auto-33']/input")$clickElement()
Sys.sleep(1L)
remDr$findElement(using = "xpath", 
                  "//*[@id='x-auto-35']/div[2]")$clickElement()
Sys.sleep(1L)
remDr$findElement(using = "xpath", 
                  "//*[@id='x-auto-14']/tbody/tr/td[2]/em/button")$clickElement()

As you can see new "window" pop up. If I try to select any of the elements in new window but it returns and error. How could I download captcha picture or wright something in text box? I tried windows handlers, but it's not a new window.

EDIT:

I have found on several places that I should use javascript to click hidden elements. I tryed:

script <- "return document.getElementById('x-auto-135').hidden;"
remDr$executeScript(script, args = list())

but get an error:

Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: java.lang.NullPointerException
     Further Details: run errorDetails method

EDIT2

I have also tried to move mouse to specific point and click. But it doesn't help since it ca'nt actiave the element by click, it is still hidden.

MislavSag avatar Jan 30 '18 18:01 MislavSag

I finally did it:

remDr$findElement(
  using = "css selector",
  ".x-window input[class=' x-form-field x-form-text ']")$sendKeysToElement(list("ded24", key = "enter"))

Can be closed

MislavSag avatar Jan 30 '18 22:01 MislavSag