robocorp / rpaframework

Collection of open-source libraries and tools for Robotic Process Automation (RPA), designed to be used with both Robot Framework and Python
https://www.rpaframework.org/
Apache License 2.0
1.14k stars 218 forks source link

Cannot locate web element by ID #139

Closed allyvan1314 closed 3 years ago

allyvan1314 commented 3 years ago

I have a combobox with id 'documents' and Robocorp cannot locate element by id.

Here is my website: https://portal.easycredit.vn/extranet/loanRequest.do

Screen Shot 2021-02-04 at 11 15 47

Here is my code in task.robot:

*** Tasks ***
Attach to running Chrome Browser and execute Google search
    Attach Chrome Browser    9222
    Go To    https://portal.easycredit.vn/extranet/loanRequestLanding.jsp?extranet=true
    Select From List By Value   id:employeeType     E
    #Click Element    id:
    Select From List By Index   id:documents    29

Error message:

==============================================================================
Robocode Lab :: Executes a search on Google.com using an already open Chrom...
==============================================================================
Attach to running Chrome Browser and execute Google search            | FAIL |
NoSuchElementException: Message: Could not locate element with index 29
------------------------------------------------------------------------------
Robocode Lab :: Executes a search on Google.com using an already o... | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output:  /var/folders/bj/s70ctr4x2jx6x7z1mdrnx62m0000gn/T/tmp3moje8us/output.xml
osrjv commented 3 years ago

Hi,

I think the problem is that those dropdowns are a custom implementation and require you to first click on the element before the list becomes visible. Seems to work like this:

Select values
    Open Available Browser       https://portal.easycredit.vn/extranet/loanRequestLanding.jsp?extranet=true
    Click Element                //button[@data-id="employeeType"]
    Select From List By Value    //select[@name="employeeType"]    E
    Click Element                //button[@data-id="documents"]
    Select From List By Index    //select[@name="documents"]       29

For future questions about using the libraries I suggest posting to our forums. This issue tracker is for reporting bugs and feature requests for the libraries, not for problems with implementations. It will also benefit other people to see solutions to problems, and the forums have more people that can help.