-
Notifications
You must be signed in to change notification settings - Fork 672
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
Test cafe fails to switch to new Window #8270
Comments
We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news. |
Hello, after taking a closer look at your example, I found that the workaround with two clicks actually works. Your test failed because of the incorrect way of checking a new window URL. You call the following method before a new window is opened, and it stores the value of the parent URL:
It won't change after a click on the 'Read more' anchor element. Instead, call the following method after clicking the 'Read more' anchor element:
Please try this and let us know your results. I will close this issue for now. |
I did the same with the const getUrl = await t.eval(() => window.location); after clicking, The system gives the error saying Cannot switch to the window. |
Hello, Could you please elaborate on the following points:
What command line did you use to run your test? Also, at what point did you get the error message? Did you use the workaround with two consecutive clicks instead of just one? Please share as much details as possible. Thank you in advance. |
The exact code == import { fixture
}) test(
}).meta('testType', 'common'); We are getting error on Line number 38. getUrl = await t.eval(() => window.location); error = Cannot switch to the window. |
Hello, I did not manage to reproduce the issue. Please provide your complete test report when getting the:
Could you also record a video of your test run showing the error? |
default.mp4Command ' npx testcafe chrome .\tests\Functional\centers.ts --disable-native-automation -e --video artifacts/videos --video-options singleFile=true,failedOnly=true,pathPattern=${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}.mp4 Error= unning tests in:
Center Finder test cases
t.click(Selector('mat-sidenav#rightsidenav').find('section.sidenav__section').nth(0).find('section.tile-accreditation').withText(/Health t.click(Selector('mat-sidenav#rightsidenav').find('section.sidenav__section').nth(0).find('section.tile-accreditation').withText(/Health t.expect(getUrl.href).eql(
1/1 failed (1m 23s) Warnings (1):The browser window was resized during the "1648 Verify the content of |
Hello, I tried to reproduce the issue again with the code you previously sent, but it does not work anymore. Has there been any changes to your website? Could you please send the updated test code? Also, did you resize the browser window during test execution? |
What is your Scenario?
Login to System after entering credentails
Clicks on the url to open a new Window.
The new window gets closed the moment it opens.
Got a work Around from the nelow Id
#6926
Again clicked on the same link.
The Test cafe fails to switch to new window and the window keeps on loading
What is the Current behavior?
The new window keeps on loading. but if you do it manually , the new window gets opened in 5 seconds.
What is the Expected behavior?
It should switch to new window and get the url , the system should match with expected url
What is the public URL of the test page? (attach your complete example)
https://mybhtest.bhdts.com/
What is your TestCafe test code?
import {
Selector,
} from 'testcafe';
fixture
Center Finder test cases
.beforeEach(async t => {await t.maximizeWindow();
await t.navigateTo('https://mybhtest.bhdts.com/');
await t.expect(Selector('section.hero').filterVisible().exists).ok('Landing Page has not been displayed.', { timeout: 60000 });
await t.wait(4000)
await t.click(Selector('div#onetrust-banner-sdk').find('button#onetrust-accept-btn-handler'));
await t.click(Selector('header.header-container').find('button>span').withText(/Log [Ii]n/));
await t.click(Selector('div#onetrust-banner-sdk').find('button#onetrust-accept-btn-handler'));
await t.typeText(Selector('bh-employer-search').find('#employer'), "Roche")
await t.expect(Selector('div[role="listbox"]').filterVisible().exists).ok({ timeout: 20000 })
await t.click(Selector('div[role="listbox"]').find('mat-option').withExactText("Roche"))
await t.click(Selector('bh-employer-search').find('button[type="submit"]'))
await t.typeText(Selector('bh-credentials').find('#username'), "testroche")
await t.typeText(Selector('bh-credentials').find('#current-password'), "User123BH")
await t.click(Selector('bh-credentials').find('button').withAttribute('type', 'submit'));
})
test(
1648 Verify the content of 'Learn more' menu - BH center
, async t => {// Display Child Care benefits (including center)
const getUrl = await t.eval(() => window.location);
}).meta('testType', 'common');
Your complete configuration file
No response
Your complete test report
AssertionError: Redirected to the wrong URL.: expected 'https://mybhtest.bhdts.com/home' to deeply equal
'https://www.brighthorizons.com/health-safety'
-https://mybhtest.bhdts.com/home
+https://www.brighthorizons.com/health-safety
Screenshots
No response
Steps to Reproduce
1.launch "https://mybhtest.bhdts.com/".
2.Click on the accept cookies
3.click on the Login In Button
4. Enter "Roche" in the employer field.
5. Select Roche from the drop Down.
6. Click on the Continue Button.
7. Enter ID as "testroche"
8. Password as "User123BH"
9. Click on Login Button.
10. Scroll to Recommended Bright Horizons centers
11. Click on the header to expand.
12. for center named Bright Horizons at Cranberry, click on learn More.
13. A new side scroll nav window opens.
14. Under "Health and safety is our top priority" click on Read more button.
TestCafe version
3.6.5
Node.js version
v20.12.0
Command-line arguments
npx testcafe chrome .\tests\Functional\centers.ts --disable-native-automation
Browser name(s) and version(s)
chrome
Platform(s) and version(s)
Windows
Other
If you are not getting the center as "Bright Horizons at Cranberry" ,
click on account >> profile
Under Zip Code : 16066
click on the save button.
Click on Life Stages.
check if early years is checked and after making chnages, click on save button.
click on Intrerest.
check if Caring Responsibility is checked and after making chnages, click on save button.
This enables the system rto get the recommended BH center in the System.
The text was updated successfully, but these errors were encountered: