'Change a agSelectCellEditor drop down value using selenium

I am trying to access values in a drop down which when I inspect, nothing is been in element inspector. I confirmed with developer what type of drop down is that he said agSelectCellEditor drop down. We then tried using following Javascript code in console which was changing the drop down values.

var x=document.querySelector("div[aria-colindex='3'][class='ag-cell ag-cell-not-inline-editing ag-cell-auto-height ag-cell-value ag-cell-wrap-text ag-cell-focus']
x.textContent="Custodian"

So that changed the drop down value from default value to Custodian. Now I tried to inject this code in JavaScriptExecutor like this.

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("var x=document.querySelector(\"div[aria-colindex='3'][class='ag-cell ag-cell-not-inline-editing ag-cell-auto-height ag-cell-value ag-cell-wrap-text ag-cell-focus']\")"
+ "x.textContent=\"Custodian\";");

It is giving me exception org.openqa.selenium.JavascriptException: javascript error: Unexpected identifier

Please help me automating this using Selenium. How to deal with this dropdown?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source