cancel
Showing results for 
Search instead for 
Did you mean: 

Help javascript select element Chrome

BenRPA
Level 4
Hi, I have been trying to use Javascript to select an element in a list in a web app through Chrome browser. I have tried using Chrome, UIA and AA and I was unable to select an element in a drop down list. When I do it, it shows on the page that the item was selected, however, it doesn't really select it (If it was selected, a textbox would disappear which is what happens if you select it manually). I have tried inserting the following code (which doesn't thrown any error). The itemID was taken from the actual "Web ID" of the element found when I spied the element with Chrome. "function getElementID(param) { document.getElementById('itemID').value = param.param } I created a variable called argument: [{ "param" : "Completed"}]. I then invoke the function by its name, and try to pass the argument "argument", but it doesn't work. Even though "Completed" is part of the item list, the dropdown list default value is replaced by "" (blank).   Anyone has worked with this before? Thanks! Ben
5 REPLIES 5

NileshJadhav1
Level 3
Hi Ben,   I am still thinking about why you are use java script to select value from dropdown list. You can use direct AA spy mode or use send key to achieve your goal. Thanks Nil  

BenRPA
Level 4
Hi Nilesh,   I am using it because AA is not available and that UIA isn't working properly as well. Isn't the javascript solution robust compared to AA?   Have you ever used it? Thanks! Ben

MaartenSteurs
Level 2
Hi Ben, 

Had the same issue and this worked for me:
-Select the item using "select list item" with element spyed in browser mode
-Use insert Javascript Fragment on element with the fragment: 
function myFunction() {
var list = document.getElementsByClassName('ClassName')[0];
var event = new Event('change');
list.dispatchEvent(event);
}

(Adjust the classname with the classname of element.)
-Use Invoke Javascript Function on element with function name "myFunction"


------------------------------
Maarten Steurs
------------------------------

Hi Ben,


Is this issue fixed? If it is please let me kniw the steps you followed.

Thanks,
Harish

------------------------------
Harish
RPA Developer
------------------------------

@Maarten Steurs same can be applicable for textbox ?

we have entered the value in textbox. But the value was not consider. 
Once we keystroke value in textbox, it will change to green  background. If no value in textbox, it will have red background.

Currently we have red background when we post the value from BP. Is there any way to trigger the javascript for that textbox class/id/name ?

Can you help us ?


------------------------------
sabarirajan m
------------------------------