0

I'm writing a small java application to automate report downloading using Selenium and the IE Webdriver. There are twenty fields which can be selected by a user in one area, and then by clicking a button, the field is moved from availabaleFieldsList to selectedFieldsList. An HTML sample is below.

Is it possible to execute some javascript on the page to insert all values in the selectedFieldsList? Similar to JavaScriptExecutor js = (JavascriptExecutor)driver; js.executeScript("document.getElementById('id').removeAttribute('attribute')");

<select name="BLANK.availableFieldsListArray" multiple="multiple" size="8" style="width:200;" id="availableFieldsListArray">
<option value="20~L0145~BLANK20~custom" selected="selected">Blank 20</option>
</select>

<select name="BLANK.selectedFieldsList" multiple="multiple" size="8" style="width:200;" id="selectedFieldsList"> 
<option value="1~L0117~BLANK1~null">Blank 1</option>
<option value="2~L0101~BLANK2~null">Blank 2</option>
<option value="3~L0119~BLANK3~null">Blank 3</option>
</select>
Kurter21
  • 63
  • 2
  • 8
  • Wouldn't it be better to let `Selenium` do it as if an end user would do? Just thought – Saifur May 15 '15 at 18:19
  • The starting selected fields are not always the same. If a report is downloaded manually there could be fields already or in the wrong order (compared to the automated download). – Kurter21 May 15 '15 at 18:29
  • In that case you always find out the number of options available and select the element using index. I am not clear what is the intend behind using javascript? – Saifur May 15 '15 at 18:31
  • You can add options to a select tag as follows: http://stackoverflow.com/questions/8674618/adding-options-to-select-with-javascript – FDM May 15 '15 at 18:58

0 Answers0