Bird
0
0

You want to write a test that visits the home page using baseUrl but also test a full external URL. How should you write the visit commands?

hard📝 Application Q9 of 15
Cypress - Navigation and URL
You want to write a test that visits the home page using baseUrl but also test a full external URL. How should you write the visit commands?
AUse <code>cy.visit('/')</code> for baseUrl and <code>cy.visit('https://external.com')</code> for external
BUse <code>cy.visit(baseUrl)</code> and <code>cy.visit(externalUrl)</code> variables
CAlways use full URLs for both visits
DSet baseUrl to external URL before visiting
Step-by-Step Solution
Solution:
  1. Step 1: Use relative path for baseUrl visit

    cy.visit('/') appends '/' to baseUrl automatically.
  2. Step 2: Use full URL for external site

    cy.visit() with full URL visits that site ignoring baseUrl.
  3. Final Answer:

    Use cy.visit('/') for baseUrl and cy.visit('https://external.com') for external -> Option A
  4. Quick Check:

    Relative path for baseUrl, full URL for external [OK]
Quick Trick: Use '/' for baseUrl, full URL for external visits [OK]
Common Mistakes:
  • Using variables without definition
  • Always full URLs
  • Changing baseUrl dynamically in test

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes