New to RSelenium and xpaths, and though some questions have been asked about this topic I can't seem to make it work for me. I am trying to download the CSV file for the first widget on the page called "Interest over time". This option does not have a unique ID/class etc, but is the third of class "widget-actions-item", where the class "widget-actions-item-text" contains "CSV".
library(RSelenium)
library(wdman)
driver <- rsDriver(browser = "firefox")
remDr <- driver[["client"]]
remDr$open
remDr$navigate("http://trends.google.com/trends/explore?cat=3")
webElem1 <- remDr$findElement("class name", "widget-actions-menu")
webElem1$clickElement()
The above code flips open the webpage and the first widget menu with three download options, of which one is CSV.
webElem2 <- remDr$findElement("xpath", paste0("//div[@class='widget-actions-content']//[@class='widget-actions-item'][3]"))
webElem2$clickElement()
The driver cannot find this element.
<div class="widget-actions-content" ng-show="widgetActions.menuOpen" aria-hidden="false" style="">
<!----><button class="widget-actions-item" ng-if="showActionButton()" ng-click="embed()" title="Embed" track="['Widget', type, 'Embed']" ve-tracking="" jslog="39389; track:generic_click">
<span class="widget-actions-item-icon embed-image flip-rtl"></span>
<div class="widget-actions-item-text">
Embed
</div>
</button><!---->
<!----><button class="widget-actions-item" ng-if="isEditor || share" ng-click="share()" title="Share" track="['Widget', type, 'Share']" ve-tracking="" jslog="39390; track:generic_click">
<span class="widget-actions-item-icon share-image flip-rtl"></span>
<div class="widget-actions-item-text">
Share
</div>
</button><!---->
<!----><button class="widget-actions-item" ng-if="isEditor || (export && showActionButton())" ng-click="export()" title="CSV" track="['Widget', type, 'Export']" ve-tracking="" jslog="39388; track:generic_click">
<span class="widget-actions-item-icon csv-image flip-rtl"></span>
<div class="widget-actions-item-text">
CSV
</div>
</button><!---->
<help-dialog ng-show="!$root.globals.isDesktopMode && helpDialog" class="widget-actions-item ng-hide" show-annotation="true" data="helpDialog" aria-hidden="true"><button class="help-icon-button" ng-click="openDialog()" title="Help">
<i class="material-icons-extended help-icon-color">help_outline</i>
<div class="widget-actions-item-text" ng-show="showAnnotation" aria-hidden="false">
Help
</div>
</button>
</help-dialog>
</div>