cypress-visit-with-custom-geolocation
v1.0.4
Published
Custom geo location
Downloads
762
Maintainers
Readme
cypress-visit-with-custom-geolocation
This will describes how to set up the custom geo location. Also you can use this if you dont have permission to enable location on your browser.
When to use this
- Dont have permission to browser to enable the geo location
- Want to test fucntionality for diff geolocation or gps tracker
Below two functions are added
visitWithCustomGeoLoc(url, latitude, longitude)
setGeoLocation(latitude, longitude)
pkg version >= 1.0.4 && cypress version >=9.5.3
visitWithCustomGeoLoc(win, url, latitude, longitude)
setGeoLocation(win, latitude, longitude)
How to use in your cypress application
Install package
npm i cypress-visit-with-custom-geolocation
Add custom command to your commands.js file
Go to /cypress/support/commands.js and add below code.
import {registerCommand} from 'cypress-visit-with-custom-geolocation'
registerCommand();
visitWithCustomGeoLoc()
Usage in your script
cy.visitWithCustomGeoLoc("https://goole.com", 51.507351, -0.127758);
if pkg version >= 1.0.4 && cypress version >=9.5.3
cy.window().then(win => { cy.visitWithCustomGeoLoc(win, "https://goole.com", 51.507351, -0.127758); })
Defalt location to London
cy.visitWithCustomGeoLoc("https://goole.com")
if pkg version >= 1.0.4 && cypress version >=9.5.3
cy.window().then(win => { cy.visitWithCustomGeoLoc(win, "https://goole.com"); })
setGeoLocation()
Usage in your script
cy.setGeoLocation(51.507351, -0.127758);
if pkg version >= 1.0.4 && cypress version >=9.5.3
cy.window().then(win => { cy.setGeoLocation(win, 51.507351, -0.127758); })
Defalt location to London
cy.setGeoLocation();
if pkg version >= 1.0.4 && cypress version >=9.5.3
cy.window().then(win => { cy.setGeoLocation(win); })
Working example
https://github.com/gaikwadamolraj/custom-geo-location-cypress
Author
Amol Gaikwad