-
Notifications
You must be signed in to change notification settings - Fork 659
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
Client function behaves differently depending on where I start my test #3775
Comments
Thank you for providing the test example. To address the problem, it is necessary to wait until the // first case
const getPageUrl = ClientFunction(() => location.toString());
await t.expect(getPageUrl()).eql('https://www.change.org/', { timeout: 5000 });
// second case
const isAppExists = ClientFunction(() => !!window.App);
await t.expect(isAppExists()).ok({ timeout: 5000 }); Let me know if this solution works for you. |
Thanks for your response. Sadly the above didn't work for me, it times out regardless of how long I set the timeout to be... (even 5mins). I understand that it is just a case of waiting for the App variable to appear... but I'm not sure why TestCafe is unable to locate the window.App in this given scenario... when other frameworks don't appear to have another issue. |
I've tried the solution from #3775 (comment) and it works fine (see video). const isAppExists = ClientFunction(() => !!window.App);
test
.page('www.change.org/login_or_join')
.only
('Start from homepage', async t => {
await t
.maximizeWindow()
.navigateTo('/login_or_join')
.typeText(Selector('#content input[type="email"]'), '******')
.typeText(Selector('#content input[type="password"]'), '*****')
.click(Selector('#content input[type="submit"]'))
.expect(isAppExists()).ok();
console.log(await changeUserState('guest'));
}); |
The issue I'm observing is when the test doesn't start from the login page (as stated in the Current Behaviour section):
I also verified that using the scenario you have outlined (starting from the login page and navigating to the login page) results in App being found... my only issue is when there is no test.page('***') argument. As stated, I can add in any number of waits, to ensure the page has completely loaded, but this hasn't helped. This isn't a blocker for me given that I'm able to use test.page('***') to work around this issue, I'm just raising it as a noticeable difference in behaviour. |
Hello, I ran the "no test.page('***')" scenario and there were no errors. Please check out this sample test: import { Selector, ClientFunction } from 'testcafe';
fixture`Change User State`.page('www.change.org');
const isAppExists = ClientFunction(() => !!window.App);
const changeUserState = ClientFunction((desiredState) => {
const initialState = App.get('currentUser').get('login_state');
App.get('currentUser').set('login_state', desiredState);
const currentState = App.get('currentUser').get('login_state');
return { initialState, currentState };
});
test
('Start from homepage', async t => {
await t
.maximizeWindow()
.navigateTo('/login_or_join')
.typeText(Selector('#content input[type="email"]'), '*****')
.typeText(Selector('#content input[type="password"]'), '*****')
.click(Selector('#content input[type="submit"]'))
.expect(isAppExists()).ok(); // wait for App
console.log(await changeUserState('guest'));
}); Result:
|
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. |
What is your Test Scenario?
I'm trying to access a Rendr App via the console window of our website. As mentioned in my SO question, I'm able to do this without any issues using a number of different frameworks (Cypress.io, Puppeteer, Protractor etc), but I get inconsistent results using TestCafe.
What is the Current behavior?
If I start my test from our homepage and navigate to the login page, then I receive an error (regardless of waiting x length of time for the page to completely load)... but if I start the test directly from the login page (test.page('login.page') etc), then the App is found more often than not.
What is the Expected behavior?
I understand that Client Functions won't wait for the page to finish loading prior to executing... however I would expect consistent results if I navigate to a page and wait for it to load completely (wait for elements to appear, then pause for 5/10/15 seconds etc), than if I start the test from that page
What is your web application and your TestCafe test code?
Your website URL (or attach your complete example):
www.change.org
Your complete test code (or attach your test files):
Here's an example of my test code. The 1st test is able to locate the client App, however (regardless of wait time) the 2nd test is unable to locate it.I've used our live website in the example, however I'm able to provide access to one of our demo sites (providing details via a private message etc)
Your complete test report:
As you can see, the App isn't recognised for the 2nd test. ```ReferenceError: App is not defined Browser: Chrome 74.0.3729 / Mac OS X 10.14.4 Screenshot: /Users/rcooper/work/regression-qaa/artifacts/screenshots/2019-05-06_15-44-22/test-2/Chrome_74.0.3729_Mac_OS_X_10.14.4/errors/1.png 38 | .navigateTo('/login_or_join') 39 | .typeText(Selector('#content input[type="email"]'), 'EMAIL') 40 | .typeText(Selector('#content input[type="password"]'), 'PASSWORD') 41 | .click(Selector('#content input[type="submit"]')); 42 | > 43 | console.log(await changeUserState('guest')); at changeUserState (/Users/rcooper/work/regression-qaa/tests/non_payments/testCafe_test.js:43:27) ]]> </failure>
The text was updated successfully, but these errors were encountered: