cypress

In cypress, how do I wait for a page to load?

有些话、适合烂在心里 提交于 2019-12-19 00:19:09
问题 Don't tell anyone, but our app is not yet single-page. I can wait on a given XHR request by giving the route an alias, but how do I wait until some navigation completes and the browser is safely on a new page? 回答1: You can add some assert inside: cy.click('#someButtonToNavigateOnNewPage'); cy.location('pathname', {timeout: 60000}) .should('include', '/newPage'); cy.click('#YouAreOnNewPage'); You can change default timeout - by default it's 4000 ms (4 secs) - to ensure that user navigated the

How to select nth item inside select element in cypress

半腔热情 提交于 2019-12-18 14:09:18
问题 say I have the HTML: <select name="subject" data-testid="contact-us-subject-field"> <option value="What is this regarding?">What is this regarding?</option> <option value="Partnerships">Partnerships</option> <option value="Careers">Careers</option> <option value="Press">Press</option> <option value="Other">Other</option> </select> Selecting an option with a known value, such as 'Careers' is as easy as: cy.get('[data-testid="contact-us-subject-field"]').select('Careers'); How do I select the

Access element whose parent is hidden - cypress.io

混江龙づ霸主 提交于 2019-12-18 04:36:09
问题 The question is as given in the title, ie, to access element whose parent is hidden. The problem is that, as per the cypress.io docs : An element is considered hidden if: Its width or height is 0. Its CSS property (or ancestors) is visibility: hidden. Its CSS property (or ancestors) is display: none. Its CSS property is position: fixed and it’s offscreen or covered up. But the code that I am working with requires me to click on an element whose parent is hidden, while the element itself is

Access a new window - cypress.io

筅森魡賤 提交于 2019-12-17 18:35:59
问题 The question is as simple as that. In Cypress, how can I access a new window that opens up when running the test. Steps to recreate : Run the test. After some action, new window pops up (the url is dynamic in nature). Fill in the fields in the new window, and click a few buttons. After required actions are completed in the new Window, close the new window and move back to the main window. Continue execution with the main window. Point of interest: the focus should be main window -> new window

Wait for multiple XHR requests to the same url or endpoint

你说的曾经没有我的故事 提交于 2019-12-13 17:41:56
问题 In Cypress, I have multiple requests that will match my cy.route() declaration. I want to make sure more than one request is made on the route. How do I tell Cypress to wait for multiple XHR requests to the same url? 回答1: From the Cypress Docs: You should set up an alias (using .as()) to a single cy.route() that matches all of the XHRs. You can then cy.wait() on it multiple times. Cypress keeps track of how many matching XHR requests there are. cy.server() cy.route('users').as('getUsers') cy

Cypress.io: Anyway to test for specific scroll amount?

有些话、适合烂在心里 提交于 2019-12-13 15:22:02
问题 Wanted to know if there is some way to test for scroll amount, within a certain range with Cypress.io. More Specifically Starting from top of page, press button Page scrolls down to a certain height Test whether scroll height is correct within a certain range My attempt: The way I assume would be best is to test that would to test out, that a current div is not within the viewable area of phone screen. Then to scroll down so it does become viewable. cy.get('#angular-projects').should('not.be

Run Cypress.io on VSTS Hosted Linux

不羁岁月 提交于 2019-12-13 15:16:54
问题 I'm trying to run Cypress tests on the Hosted Linux Pool for Visual Studio Team Services. Unfortunately, the Hosted Agent doesn't have all the dependencies for Cypress installed. Running the documented apt-get doesn't work: 2018-05-18T21:03:14.7423331Z ##[section]Starting: Install cypress dependencies 2018-05-18T21:03:14.7474742Z ============================================================================== 2018-05-18T21:03:14.7488281Z Task : Bash 2018-05-18T21:03:14.7501148Z Description :

Cypress:Is there any way to check invisibility of an element

左心房为你撑大大i 提交于 2019-12-13 03:47:31
问题 In our application when user do some actions that require communicatiion with server -a loading bar will be displayed on top panel.Once the action completed-Loading bar will be disappeared.In tests we are using this as a check before we move to next step. In selenium i am checking the disappearance of loading bar as shown below WebDriverLongWait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.Id("loading-bar"))); Is there a similar way to check invisibility of an element in Cypress

Not able to Switch Windows using stub and spy using Cypress

a 夏天 提交于 2019-12-13 03:26:01
问题 I am facing Issue in switching windows within my CRM web Application using Stub methods. Getting below error message Timed out retrying: { [Function: open] callBaseMethod: { [Function] callBaseMethod: [Circular], getBaseMethod: { [Function] callBaseMethod: [Circular], getBaseMethod: [Circular], resolveInheritance: [Circular], registerEnum: [Circular] }, registerEnum: [Circular] } } is not a spy or a call to a spy! Because this error occurred during a 'before each' hook we are skipping the

How to get values of multiple aliases without introducing callback hell in Cypress?

◇◆丶佛笑我妖孽 提交于 2019-12-12 16:03:00
问题 Say I want to retrieve the values of two Cypress aliases and use it in my test case. How do I do so without nesting them in the following manner? cy.get('@alias1') .then((alias1) => { cy.get('@alias2').then((alias2) => { someFunctionThatUsesBothAliases(alias1, alias2); }) }) 回答1: You can do this: it('test', () => { cy.wrap('foo').as('foo'); cy.wrap('bar').as('bar'); cy.wrap('baz').as('baz'); const values = []; cy.get('@foo').then( val => { values.push(val); return cy.get('@bar'); }).then( val