Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Fixture, how can I send the page instance for multiple pages. #16768

Closed
oscargforce opened this issue Aug 23, 2022 · 3 comments
Closed

Comments

@oscargforce
Copy link

oscargforce commented Aug 23, 2022

Hello!

See the attached picture for my code.
I need to automate chat functionality between two browsers.

patientAppPages is one page object for the patient chat.
clinicPages is another page object from the practitioner PoV.

image

PatientAppPages can be controlled by adding "page" fixture in my test like this:
it("should work ", async ({page, clinicPages, patientAppPages }) => { await page.goto("https://patientApp.com") })

But there is no way for me to navigate to the clinicPages url or to control that instance of the page.
It simply creates a blank page.

I do not want to navigate to the url in the fixture. I need the page instance for clinicPages for my other functions.

Is this possible?

@yury-s
Copy link
Member

yury-s commented Aug 23, 2022

You can store the page in the wrapper classes and then expose it to the tests:

// Assuming one of the POM classes defined like this:
class ClinicPages {
    page: Page;
    constructor(page: Page) {
        this.page = page;
    }
    async gotoLandingPage() {
        await this.page.goto('https://clilic-url');
    }
};

// In the test you can do something like this:
it("should work ", async ({clinicPages, patientAppPages }) => {
    await patientAppPages.page.goto("https://patientApp.com");
    await clinicPages.page.goto('https://clilic-url');
    // or alternatively using POM method:
    await clinicPages.gotoLandingPage();
})

Will that work for you?

@oscargforce
Copy link
Author

Yes thank you 🙏

@pavelfeldman
Copy link
Member

Closing as per above, please feel free to open a new issue if this does not cover your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants