Topic Thread

Expand all | Collapse all

Help javascript select element Chrome

  • 1.  Help javascript select element Chrome

    Posted 04-13-2019 03:32
    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


  • 2.  Hi Ben,   I am still…

    Posted 04-15-2019 11:04
    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  


  • 3.  Hi Nilesh,   I am using it…

    Posted 04-15-2019 18:37
    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


  • 4.  RE: Help javascript select element Chrome

    Posted 11-28-2019 07:42
    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
    ------------------------------



  • 5.  RE: Help javascript select element Chrome

    Posted 05-15-2020 14:30
    Hi Ben,


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

    Thanks,
    Harish

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