1

On the following web site: https://www.bhtelecom.ba/index.php?id=7226&a=new I want to choose second value in drop down window ("Tuzlanski (035)") that apperad after you click on "Sarajevo (033)". I want to do that using RSelenium.

I tried 10 different solutions I found on stackoverflow but non of it works. I thinks it is because it is generated by javascript.

One of my tried solution:

remDr <- remoteDriver(remoteServerAddr = "192.168.99.100", port = 4445L,
                      browserName = "chrome")
remDr$open()
remDr$navigate("https://www.bhtelecom.ba/index.php?id=7226&a=new")
option <- remDr$findElement(using = 'xpath', "//select[@id='di']/option[@value='035']")
option$clickElement()

1 Answer 1

1

Firstly you have to click on input field:

input <- remDr$findElement(using = 'xpath', "//input[@class = 'select-dropdown']")
input$clickElement()

then options will be visible and you can select them using right xPath:

option <- remDr$findElement(using = 'xpath', "//span[contains(., 'Tuzlanski (035)')]")
option$clickElement()

Probably you will may need to use this:

Sys.sleep(5) # wait 5 seconds

if the script will be too quick and will try to select dropdown element before dropdown will appear.

Summary code:

input <- remDr$findElement(using = 'xpath', "//input[@class = 'select-dropdown']")
input$clickElement()

Sys.sleep(5) # wait 5 seconds

option <- remDr$findElement(using = 'xpath', "//span[contains(., 'Tuzlanski (035)')]")
option$clickElement()

You have also wrong xPath: enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

I doesn't work for me: It gives me an error Error: Summary: ElementNotVisible fo the last command (option$clickelement())
Add Sys.sleep(5) after input$clickElement()
It doesn't help
I have found the issue, there was wrong xPath, please have a look on the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.