DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.81k stars 669 forks source link

Test cafe fails to switch to new Window #8270

Open pranabkdas85 opened 2 weeks ago

pranabkdas85 commented 2 weeks ago

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 https://github.com/DevExpress/testcafe/issues/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';

fixtureCenter 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'));

await t.expect(Selector('app-top-picks').find('.carousel')().filterVisible().exists).ok({ timeout: 60000 })

})

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);

await t.expect(getUrl.href).eql(`https://mybhtest.bhdts.com/home`, { timeout: 120000 })
await t.expect(Selector('#dashboard_walkthrough').filterVisible().exists).ok({ timeout: 120000 })
// Find a card and open the 'Learn more' menu
await t.click(Selector('app-recommended-centers').find('button.header__button'))
const card: Selector = Selector('app-recommended-centers').find('div.centers__wrapper>app-scroll-wrapper  div.wrapper__container').find('app-center-card').find('.center-card__center-name').withText('Bright Horizons at Cranberry').parent('app-center-card').nth(0);

await t.click(card.find('app-link span').withExactText('Learn more'));
// Verify the content of the menu
await t.click(Selector('mat-sidenav#rightsidenav').find('section.sidenav__section').nth(0).find('section.tile-accreditation').withText(/Health and [Ss]afety is [Oo]ur [Tt]op [Pp]riority/).find('a').withExactText('Read more'));
await t.click(Selector('mat-sidenav#rightsidenav').find('section.sidenav__section').nth(0).find('section.tile-accreditation').withText(/Health and [Ss]afety is [Oo]ur [Tt]op [Pp]riority/).find('a').withExactText('Read more'));
await t.expect(getUrl.href).eql(`https://www.brighthorizons.com/health-safety`, 'Redirected to the wrong URL.')
await t.closeWindow();

}).meta('testType', 'common');

Your complete configuration file

No response

Your complete test report

1) AssertionError: Redirected to the wrong URL.: expected 'https://mybhtest.bhdts.com/home' to deeply equal 'https://www.brighthorizons.com/health-safety'

  + expected - actual

  -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

  1. Enter "Roche" in the employer field.
  2. Select Roche from the drop Down.
  3. Click on the Continue Button.
  4. Enter ID as "testroche"
  5. Password as "User123BH"
  6. Click on Login Button.
  7. Scroll to Recommended Bright Horizons centers
  8. Click on the header to expand.
  9. for center named Bright Horizons at Cranberry, click on learn More.
  10. A new side scroll nav window opens.
  11. 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.

github-actions[bot] commented 2 weeks ago

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.