Challenge - 5 Problems
Page Navigator Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the result of this cy.visit() command?
Consider this Cypress test code snippet:
Assuming the baseUrl is set to 'https://example.com', what URL will Cypress navigate to?
cy.visit('/dashboard')Assuming the baseUrl is set to 'https://example.com', what URL will Cypress navigate to?
Cypress
cy.visit('/dashboard')Attempts:
2 left
💡 Hint
The path in cy.visit() appends to the baseUrl without doubling slashes.
✗ Incorrect
When cy.visit() is given a path starting with '/', it appends that path to the baseUrl. It does not add extra slashes. So '/dashboard' becomes 'https://example.com/dashboard'.
❓ assertion
intermediate1:30remaining
Which assertion correctly verifies the page loaded after cy.visit()?
After running
cy.visit('/login'), which assertion correctly checks that the URL contains '/login'?Cypress
cy.visit('/login')Attempts:
2 left
💡 Hint
Use cy.url() to get the full URL and check if it contains the path.
✗ Incorrect
cy.url() returns the full URL string. Using .should('include', '/login') checks if the URL contains the path '/login'. Option A fails because the full URL is not just '/login'. Option A checks the pathname contains 'login', which does verify the URL contains '/login'. Option A checks for 'https://login' which is incorrect.
🔧 Debug
advanced2:00remaining
Why does this cy.visit() command fail with a 404 error?
Given this code:
The test fails with a 404 error. Why?
cy.visit('dashboard')The test fails with a 404 error. Why?
Cypress
cy.visit('dashboard')Attempts:
2 left
💡 Hint
Check how relative paths without leading slash are resolved.
✗ Incorrect
Without a leading slash, Cypress appends the path directly to the baseUrl without a slash, causing an invalid URL like 'https://example.comdashboard'. This leads to a 404 error.
🧠 Conceptual
advanced1:30remaining
What happens if cy.visit() is called with an absolute URL different from baseUrl?
If baseUrl is set to 'https://example.com' and the test runs
cy.visit('https://other.com/page'), what will Cypress do?Cypress
cy.visit('https://other.com/page')Attempts:
2 left
💡 Hint
Absolute URLs override baseUrl in cy.visit().
✗ Incorrect
When cy.visit() is given a full absolute URL, Cypress navigates directly to that URL ignoring the baseUrl setting.
❓ framework
expert2:30remaining
In Cypress, how can you wait for a page to fully load after cy.visit() before running assertions?
Which approach ensures the page is fully loaded before assertions after
cy.visit('/home')?Cypress
cy.visit('/home')Attempts:
2 left
💡 Hint
Waiting for a visible element is better than fixed delays or document properties.
✗ Incorrect
Cypress automatically waits for the page load event during cy.visit(). Using .then(() => cy.get('body')) ensures the body element is present before continuing. Option C is unreliable fixed wait. Options A and D are invalid because cy.visit() does not return page properties directly.