visit function opens invalid URL

Viewed 212

I am new to cypress and writing my 1st test.

In my test, I have the following script:

describe('Navigate to login page', function() {
  it('successfully loads', function() {
    cy.visit('https://www.google.com')
  })
})

When running with TestRunner, it opens the page with the following URL:

https://www.google.com/__/#/tests/integration\login_spec.js

Is there any way to remove the appended text __/#/tests/integration\login_spec.js in the url?

Thanks, Tuyen

1 Answers

You should use cy.url() to get the current url of the app you're testing.

for example

cy.url().then(url => console.log(url))

The app url is shown above your test page. See here

enter image description here

Related