I am currently working on automating a website to create a list through input values in a text field and setting them by clicking outside the field. Due to slow performance with Internet Explorer, I am using Selenium webdriver with IE. The sendKeys method is not efficient so I am exploring the executescript method.
My attempt at this approach is shown below, however, it is not functioning as desired. I would appreciate any suggestions from those who have experience in this area.
Here is the code snippet:
//Creating an array of values for the list
String values[] = {"18","25","60","71"};
//Identifying the WebElement for entering values
WebElement searchField = driver.findElement(By.xpath("//label[text()='New value:']/parent::div//input[@type='text']"));
JavascriptExecutor myExecutor6 = ((JavascriptExecutor) driver);
//Iterating through the values array to input each value individually as required by the UI
for(int i=0; i<values.length; i++){
System.out.println(values[i]);
Thread.sleep(3000);
/*The following section attempts to input the value at index 'i' into the designated text field indicated by searchField */
/*There seems to be a JavaScript error that I cannot troubleshoot*/
myExecutor6.executeScript("var valueToWrite = values[i].toString();"
+"arguments[0].value = valueToWrite ",searchField, values[i]);
Thread.sleep(3000);
//Simulating a mouse click outside the text field to finalize the value entry
driver.findElement(By.xpath("//label[text()='Values:']")).click();
Thread.sleep(3000);
}