Mihai Ghimpu
Mihai Ghimpu

Reputation: 49

How to "CTRL + Click" in cypress, pages are linked but ctrl + click does not take me to the correct page

I have two files, a spec file and a page object file. I have imported the page object file inside the spec file. My issue is that when i try to CTRL + click on a reference inside the spec file, it does not take me to the page object file.

The test runs ok but i would like this functionality to be active. What am i missing?

Spec file:


const constants = require("../support/constants")
const positionPage = require("../support/page_objects/positionPage")


describe('Create New Position', () => {

    it('Log In', () => {
        cy.visit(Cypress.env('staging'))
        cy.logIn(Cypress.env('username'), Cypress.env('password'))
    })

    it('Expand menu', () => {
        positionPage.expandMenuButton.click()
    })

    it('Open Position menu', () =>{
        positionPage.createNewPosition('Manager')
    })

})

Page object file:

/// <reference types = "cypress" />

class PositionPage {

    get expandMenuButton () {
        return cy.get('.dash-menu-header > .mobile-menu-button')
    }

    createNewPosition (positionName) {
        cy.get('#topSearchAdd > .dropdown-toggle-mousedown').click();
        cy.get('[ng-if="currentUser.userPermissions.addPosition"] > a').click()
        cy.get('.noBottomMargin > .inputTipWrap > div > .ng-pristine').type(positionName)
    }

}

export default new PositionPage()

Thanks a lot!

Upvotes: 1

Views: 441

Answers (1)

Fody
Fody

Reputation: 31944

The require() syntax seems to be stopping it.

Switching to import

import positionPage from "../support/page_objects/positionPage"

ctrl-click here in the spec

positionPage.expandMenuButton.click()

takes you to here in positionPage

export default new PositionPage()

Upvotes: 2

Related Questions