I am trying to download a csv file from a website using RSelenium. I get to the page, which is a Crystal Report Viewer, and select the element of the export button and click that button. Then an export window appears with a file format selection. I am able to find the element of the dropdown list but I am having issues with the values of the list. The values appear to be coming from a very long javascript script like the following:
<script type="text/javascript" language="JavaScript">
`{"args":`
{"args":{"id":"CrystalReportViewer_exportUI","availableFormats":[{"name":"Crystal Reports (RPT)","value":"CrystalReports"},{"name":"PDF","value":"PDF"},{"name":"Microsoft Excel (97-2003)","value":"MSExcel"},{"name":"Microsoft Excel (97-2003) Data-Only","value":"RecordToMSExcel"},{"name":"Microsoft Word (97-2003)","value":"MSWord"},{"name":"Microsoft Word (97-2003) - Editable","value":"EditableRTF"},{"name":"Rich Text Format (RTF)","value":"RTF"},{"name":"Separated Values (CSV)","value":"CharacterSeparatedValues"},{"name":"XML","value":"XML"}]`
`</script>
The dropdown box looks like the following:
I am able to find the element related to the above dropdown box.
When I click the dropdown menu the list above shows. When I am looking at the HTML element while selecting one of the values, the value I select gets updated in the HTML code--I'm assuming from the Javascript list. It looks like the following after I click "Seperated Values (CSV)":
<div id="id_name" class="icontext" style="white-space:nowrap;text-overflow:ellipsis;overflow:hidden;width:249px">Separated Values (CSV)</div>
I tried to use the following code but it does not work:
WebElemFileFormat <- remDr$findElement(using = 'id', "id_name")
WebElemFileFormat$clickElement()
WebElemFileFormat$sendKeysToElement(list("Separated Values (CSV)"))
I read this post Selecting a javascript dropdown but not sure how that translates to RSelenium. Many thanks in advance.