cypress

Is there a programmatic way to change user agent in Cypress.io?

妖精的绣舞 提交于 2020-01-13 09:32:29
问题 I have some ad calls that are only made on mobile devices. In Chrome, I can use Device Mode and simulate a mobile device, and the resulting ad call from the server is correctly tailored to mobile. I'm not sure how Chrome does this, except possibly by sending a different user agent. In the Cypress.io documentation, it says the user agent can be changed in the configuration file (Cypress.json). But, I need to run a test for a desktop viewport and then a mobile viewport with a mobile user agent.

Is there a programmatic way to change user agent in Cypress.io?

妖精的绣舞 提交于 2020-01-13 09:31:06
问题 I have some ad calls that are only made on mobile devices. In Chrome, I can use Device Mode and simulate a mobile device, and the resulting ad call from the server is correctly tailored to mobile. I'm not sure how Chrome does this, except possibly by sending a different user agent. In the Cypress.io documentation, it says the user agent can be changed in the configuration file (Cypress.json). But, I need to run a test for a desktop viewport and then a mobile viewport with a mobile user agent.

How to reuse yielded value later in the test

偶尔善良 提交于 2020-01-09 08:19:28
问题 Context: I have an element with innerText in Page1 and another element with innerText on Page 2. And I need to compare these two values in Page 3. So I need to find a way to save these values in a variable globally so that they can be used later. Things I tried: Trial 1: Didn't work as page1value scope is limited to the cy.get() cy.get('#selector').invoke('text').then(text => { const page1value = text }) Trial 2: Didn't work as whenever I try to print the value outside, it comes as undefined

Conditional statement in cypress

若如初见. 提交于 2020-01-06 07:13:48
问题 I am trying to do a conditional statement on cypress to check if the login link in the header is Sign in or Account or a class and then click on it. The if condition is not working. cy.get('header').then((header) => { if (header.find('Sign in').length > 0) { cy.contains('Sign In') .click({force:true}) } else if (header.find('Account').length > 0) { cy.contains('Account') .click() } else { cy.get('.navUser-item--account .navUser-action').click() } }) I expect if Sign in found then it will

Conditional statement in cypress

╄→尐↘猪︶ㄣ 提交于 2020-01-06 07:13:11
问题 I am trying to do a conditional statement on cypress to check if the login link in the header is Sign in or Account or a class and then click on it. The if condition is not working. cy.get('header').then((header) => { if (header.find('Sign in').length > 0) { cy.contains('Sign In') .click({force:true}) } else if (header.find('Account').length > 0) { cy.contains('Account') .click() } else { cy.get('.navUser-item--account .navUser-action').click() } }) I expect if Sign in found then it will

How to change property of a record in db with cypress.io

瘦欲@ 提交于 2020-01-05 07:19:06
问题 i'm new to cypress and i'm wondering how can i do the following checks: I have case: I have a product in the db, that can have statuses: InStock and OutOfStock and Discontinued. If product is in 'InStock ' status, i should be able to dispatch it to a customer, if in 'OutOfStock'/ 'Discontinued' i should not be able to dispatch to a customer. With an api call i can dispatch the product to a customer. If product is in 'InStock' status, the api response is 200, if not the response is with

Sample cypress script to bypass SSO

老子叫甜甜 提交于 2020-01-05 05:41:24
问题 I am setting up new cypress tests to test some functionalities in Dynamics 365 application. But, I'm left with a browser window with the url https://login.microsoftonline.com/__/ and the text Whoops, there is no test to run. describe('Initial Cypress Tests', () => { it('navigate to D365', () => { cy.visit('https://wipropoc.crm8.dynamics.com') } ) }) 回答1: Would suggest you to directly do a POST call for getting SSO authentication token and fire cy.visit('https://wipropoc.crm8.dynamics.com')

Docker-compose exit code is 137 when there is no OOM exception

旧城冷巷雨未停 提交于 2020-01-05 03:55:09
问题 When I run the following command, I expect the exit code to be 0 since my combined container runs a test that successfully exits with an exit code of 0. docker-compose up --build --exit-code-from combined Unfortunately, I consistently receive an exit code of 137 even when the tests in my combined container run successfully and I exit that container with an exit code of 0 (more details on how that happens are specified below). Below is my docker-compose version: docker-compose version 1.25.0,

Cypress not matching routes

与世无争的帅哥 提交于 2020-01-04 05:51:06
问题 I am trying to write a cypress test that emulates a slow API, so after reading some documentation I came up with this: before(function() { cy.server({delay: 5000}); }); beforeEach(() => { cy.route({ method: "GET", url: "**/api/**" }); cy.visit("http://localhost:9000"); }); That should add a 5 second delay to all requests to API , right? The issue I am seeing is that it is not matching to any requests even through there are plenty of calls to */api/* . The cypress GUI does however see the

Cypress save contents in response body as a Alias or variable

混江龙づ霸主 提交于 2020-01-04 02:15:10
问题 I use cy.request to create a new user. I need to get the userID and use it to assemble a url. e.g.: function createUser () { cy.request({ method: 'GET', url: `/human/sign_in` }).then(response => { const $ = cheerio.load(response.body) const token = $('css to get the token') cy.request({ method: 'POST', url: `/signups/brands`, form: true, body: { 'authenticity_token': token, 'name': 'some name', 'email': 'some email' } }) }).then(response => { const $ = cheerio.load(response.body) const userID