Skip to content

Instantly share code, notes, and snippets.

@filiphric
Created October 12, 2021 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filiphric/deae1e99b6407afd0115341701bcb272 to your computer and use it in GitHub Desktop.
Save filiphric/deae1e99b6407afd0115341701bcb272 to your computer and use it in GitHub Desktop.
Changing user agent in cy.visit() command
it('changing user agent', () => {
cy.visit('/', {
onBeforeLoad: (win) => {
Object.defineProperty(win.navigator, 'userAgent', {
value: 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
});
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment