1

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:

enter image description here I am able to find the element related to the above dropdown box.

enter image description here

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.

1 Answer 1

3

After doing some more research I decided to go a different route with this. I'll leave this up in case someone comes across a similar issue. I noticed that after playing around with the dropdown box I could use the down arrow or tab to moved down the list.

I used the following code to complete what I wanted to in the question above:

`WebElemFileFormat <- remDr$findElement(using = 'id', "id_name")
remDr$setImplicitWaitTimeout(milliseconds = 10000)
WebElemFileFormat$clickElement()
remDr$sendKeysToActiveElement(list(key = 'tab'))
remDr$sendKeysToActiveElement(list(key = 'tab'))
remDr$sendKeysToActiveElement(list(key = 'tab'))
remDr$sendKeysToActiveElement(list(key = 'tab'))
remDr$sendKeysToActiveElement(list(key = 'tab'))
remDr$sendKeysToActiveElement(list(key = 'tab'))
remDr$sendKeysToActiveElement(list(key = 'tab'))
remDr$sendKeysToActiveElement(list(key = 'enter'))
`

Notice that I decided to use tab and not the down arrow. The down arrow was not working for some reason. I hope this helps someone!

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

1 Comment

I have similar problem, but want to select dropdown item by name. It also not working. In terms of your arrow maybe you've written wrong name. Type selKeys and see the names; arrows are down_arrow, etc.

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.