'Right clicking in RSelenium doesn't seem to be working

Would appreciate some help as I am stuck here.

I am trying to write an automated script to download data from the Microsoft Power BI site of the WHO, which can be found here.

But when I try to retrieve the data, the right click function doesn't seem to work - or more likely: I am doing something wrong.

I created a container on Docker that I am accessing with Selenium in R. The script below generates a click on the first page (on the "Download data" button at the lower left-hand side corner of the screen. After a long load time the next screen appears. The goal is to RIGHT-CLICK on the download button of "Vaccine uptake by target group" x "Data".

Here's two screenshots of where I need to create the first left-click and the second right-click.

enter image description here

enter image description here

I have tried multiple approaches, including first selecting the iframe, switching the frame view and then selecting an xpath pointing to the clickable area. That seemed to work.

But when I give the command to right click nothing happens as verified in the VNC rendition. The contextual menu doesn't appear.

Anyone knows what went wrong?

Here's the code I entered:

library(RSelenium)


remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox")

remDr$open()

remDr$navigate("https://app.powerbi.com/view?r=eyJrIjoiMWNjNzZkNjctZTNiNy00YmMzLTkxZjQtNmJiZDM2MTYxNzEwIiwidCI6ImY2MTBjMGI3LWJkMjQtNGIzOS04MTBiLTNkYzI4MGFmYjU5MCIsImMiOjh9") 

Sys.sleep(30) # WHO is taking its time

#This is first button to bring us to the next page

webElem <- remDr$findElement(using = "xpath", value = "/html/body/div[1]/report-embed/div/div/div[1]/div/div/div/exploration-container/div/docking-container/div/div/div/div/exploration-host/div/div/exploration/div/explore-canvas/div/div[2]/div/div[2]/div[2]/visual-container-repeat/visual-container[22]/transform/div/div[3]/div/visual-modern")
webElem$highlightElement() 

webElem$clickElement()

Sys.sleep(30) # again need some time to fully load

# This selects the iframe

webElem <- remDr$findElement(using = "xpath", value = "/html/body/div[1]/report-embed/div/div/div[1]/div/div/div/exploration-container/div/docking-container/div/div/div/div/exploration-host/div/div/exploration/div/explore-canvas/div/div[2]/div/div[2]/div[2]/visual-container-repeat/visual-container[19]/transform/div/div[3]/div/visual-modern/div/iframe") 

remDr$switchToFrame(webElem)

# This selects the area for the second click
webElem <- remDr$findElement(using = "xpath", value="/html/body/div/div/a[1]")

remDr$mouseMoveToLocation(webElement = webElem)

# And then the right-click but none of these seem to work:
remDr$click(buttonId = 2)
remDr$click('right')

Thanks for any advice.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source