Click element on browser

Hello!!!
We are creating a robot that completes a web form to obtain the coordinates of a site based on the address

we are using the following website:
https://www.coordinates-gps.com/

and we need to click on the button “get gps coordinates”

We are trying to make a click element but it does not work, we dont have “ID” on html, the html code of the button is the following:

Get GPS Coordinates

Hi!

I assume you meant the site: https://www.gps-coordinates.net/

One way to click the element is to make an XPath that targets a button with the correct text:

Click element    //button[text()='Get GPS Coordinates']

However, there’s a shorthand for this in Selenium:

Click button    Get GPS Coordinates

This will automatically click a button that has either the id, name, or value of “Get GPS Coordinates”.

BR,
Ossi

1 Like

thanks osrjv… works fine,

after that I need to get the coordinates of the field shown in the image and save it in a variable, but I am not finding the correct command.

image
html:

input id=“latlong” class=“form-control selectall” type=“text”

Hi, @Mike_Caruso!

Here is one possible solution. Still some optimization possibilities such as replacing the sleeps with logical waits:

*** Settings ***
Library           RPA.Browser.Selenium
Task Teardown     Close All Browsers

*** Tasks ***
Get coordinates using gps-coordinates.net
    Open Available Browser    https://www.gps-coordinates.net/
    Wait until geolocation and the map is active
    ${coordinates}=    Get coordinates    Chicago
    Log To Console    ${coordinates}

*** Keywords ***
Wait until geolocation and the map is active
    Wait Until Page Contains    Geolocation on
    # Scrolling activates the map.
    Scroll Element Into View    id:latitude_degres
    Sleep    1 second

*** Keywords ***
Get coordinates
    [Arguments]    ${address}
    Input Text    id:address    ${address}
    Click Button    Get GPS Coordinates
    Sleep    3 seconds
    ${coordinates}=    Get Value    id:latlong
    [Return]    ${coordinates}

If you are planning on using the coordinates often, check out the service providers API at https://opencagedata.com/. So instead of using that website, you can connect to the API.

1 Like

Perfect!!! thanks a lot!

1 Like