Override geolocation using robot framework and seleniumlib

I've trying to override geolocation using robot + seleniumLib, all docs mention this python code, using cdp commands, but how do i import this code in this case? I read something about using the keyword "Create Webdriver", but really dont know how it works. Can anyone help me with this?

.py and .robot file are in same folder.

.robot file

***Settings***
Library             SeleniumLibrary
Library             geo.py

Suite Teardown      End    
***Variables***

***Test Cases***
Test Location
    Should appear the overrided location


***Keywords***
End
    Close All Browsers

Should appear the overrided location
    Open Browser                        https://browserleaks.com/geo       Chrome 
    Wait Until Page Contains            HTML5 Geolocation API
    Scroll Element Into View            xpath://*[@id="footer"]     
    Page Should Not Contain Element     xpath://*[@alt="BR"]    #flag img from my current country location
    Sleep                               5
    Close Browser

.py file

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

def geoLocation_Test():
    driver = webdriver.Chrome()
    Map_coordinates = dict({
        "latitude": 41.8781,
        "longitude": -87.6298,
        "accuracy": 100
        })
    driver.execute_cdp_cmd("Emulation.setGeolocationOverride", Map_coordinates)


from Recent Questions - Stack Overflow https://ift.tt/3miLcOc
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation