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

page loaded event #3758

Closed
benmonro opened this issue Apr 28, 2019 · 9 comments
Closed

page loaded event #3758

benmonro opened this issue Apr 28, 2019 · 9 comments
Assignees
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: enhancement The accepted proposal for future implementation.

Comments

@benmonro
Copy link
Contributor

What is your Test Scenario?

For testcafe-testing-library, I'd like to support a use case for when navigation occurs (clicking a link, reloading, etc). In order to do this, I need to inject dom-testing-library into the DOM on each page-load

What are you suggesting?

I propose adding an event subscription which I can subscribe to in a test or hook.

await t
  .on("pageload", () => addTestcafeTestingLibrary(t))
  .click(getByText("link to other page")
  .click(getByText("link to yet another page")
  .expect(getByText("element on other page").exists)
  .ok();

What alternatives have you considered?

I have a work around, but it requires manually injecting after the link click, it works, but it's toothy and cumbersome. For example, in the example above, i have to do this:

await addTestCafeTestingLibrary(t);

await t.click(getByText("link to other page"));

await addTestcafeTestingLibrary(t);

await t.click(getByText("link to yet another page"));

await addTestcafeTestingLibrary(t);

await t
  .expect(getByText("element on other page").exists)
  .ok();

quite verbose as you can see. hence the desire to have an event I can subscribe to for whenever a page load occurs....

Additional context

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Apr 28, 2019
@AlexKamaev AlexKamaev self-assigned this Apr 29, 2019
@AlexKamaev
Copy link
Contributor

Thank you for your proposal. We'll consider its implementation with the team if the idea becomes popular.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Apr 29, 2019
@AlexKamaev AlexKamaev added the TYPE: enhancement The accepted proposal for future implementation. label Apr 29, 2019
@benmonro
Copy link
Contributor Author

benmonro commented May 3, 2019

Hi @AlexKamaev Thank you. Are there any work arounds you know of that I can use in the meantime to allow me to inject scripts into the page whenever a navigation event occurs?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label May 3, 2019
@LavrovArtem LavrovArtem self-assigned this May 6, 2019
@LavrovArtem
Copy link
Contributor

You can try to wrap the click action and use it for clicks that lead to the page reload. For example:

const clickThatLeadsToReload = async (t, selector) => {
    await t.click(selector);
    await addTestcafeTestingLibrary(t);
};

await clickThatLeadsToReload(t, getByText("link to other page"));

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label May 6, 2019
@benmonro
Copy link
Contributor Author

@AlexKamaev I'd be happy to submit a PR of you could point me in the right direction... Like where does testcafe interact with hammer head?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label May 26, 2019
@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label May 27, 2019
@benmonro
Copy link
Contributor Author

found a solution using the testRun class.

@need-response-app need-response-app bot added STATE: Need response An issue that requires a response or attention from the team. and removed STATE: Need response An issue that requires a response or attention from the team. labels May 27, 2019
@corysimmons
Copy link

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 4, 2019
@AlexSkorkin AlexSkorkin removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 4, 2019
@benmonro
Copy link
Contributor Author

benmonro commented Jun 4, 2019

Ah yes. Nice catch. Thanks

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 4, 2019
@AlexSkorkin AlexSkorkin removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 4, 2019
@corysimmons
Copy link

@benmonro No, thank you. Really excited to use these two tools together. 🙇‍♂️

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 4, 2019
@AlexSkorkin AlexSkorkin removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 4, 2019
benmonro pushed a commit to testing-library/testing-library-docs that referenced this issue Jun 4, 2019
Removed since the [issue](DevExpress/testcafe#3758) was already resolved.
@lock
Copy link

lock bot commented Jun 14, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Jun 14, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: enhancement The accepted proposal for future implementation.
Projects
None yet
Development

No branches or pull requests

5 participants