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.
- Dont have permission to browser to enable the geo location
- Want to test fucntionality for diff geolocation or gps tracker
visitWithCustomGeoLoc(url, latitude, longitude)
setGeoLocation(latitude, longitude)
visitWithCustomGeoLoc(win, url, latitude, longitude)
setGeoLocation(win, latitude, longitude)
npm i cypress-visit-with-custom-geolocation
Go to /cypress/support/commands.js and add below code.
import {registerCommand} from 'cypress-visit-with-custom-geolocation'
registerCommand();
-
cy.visitWithCustomGeoLoc("https://goole.com", 51.507351, -0.127758);
cy.window().then(win => { cy.visitWithCustomGeoLoc(win, "https://goole.com", 51.507351, -0.127758); })
-
cy.visitWithCustomGeoLoc("https://goole.com")
cy.window().then(win => { cy.visitWithCustomGeoLoc(win, "https://goole.com"); })
-
cy.setGeoLocation(51.507351, -0.127758);
cy.window().then(win => { cy.setGeoLocation(win, 51.507351, -0.127758); })
-
cy.setGeoLocation();
cy.window().then(win => { cy.setGeoLocation(win); })
https://github.com/gaikwadamolraj/custom-geo-location-cypress
Amol Gaikwad