Help javascript select element Chrome
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
13-04-19 03:32 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
15-04-19 11:04 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
15-04-19 06:37 PM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-11-19 07:42 AM
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
------------------------------
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
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-05-20 07:44 PM
Hi Ben,
Is this issue fixed? If it is please let me kniw the steps you followed.
Thanks,
Harish
------------------------------
Harish
RPA Developer
------------------------------
Is this issue fixed? If it is please let me kniw the steps you followed.
Thanks,
Harish
------------------------------
Harish
RPA Developer
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-06-22 03:46 PM
@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
------------------------------
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
------------------------------
