testcafe
testcafe copied to clipboard
New window results in 'The iframe in which the test is currently operating is not visible anymore.'
What is your Scenario?
Found while reproducing #6918. This test promotes a petition, and goes through the Paypal payment flow (pop-up window).
What is the Current behavior?
The test fails during the Paypal window, when logging in, or clicking the accept cookies button: The iframe in which the test is currently operating is not visible anymore
- However, I've also experienced this happen when the window completes and the test attempts to return to the main page.
What is the Expected behavior?
The Paypal payment button is within an iFrame. We should successfully be able to switch to Paypal window (and then back to the main window upon completion)
What is your public website URL? (or attach your complete example)
www.staging.change.org
What is your TestCafe test code?
/* global window */ import { Chance } from 'chance'; import { ClientFunction, Selector, t } from 'testcafe';
const chance = new Chance(); const emailAddress = chance.email(); const paypalIframe = Selector('[data-testid="paypal-button"] iframe').withAttribute('src'); const ppmuPaypalIframe = Selector('#modal-paypal-button iframe').withAttribute('src'); const payWithPaypalButton = Selector('[data-funding-source="paypal"]').filterVisible();
// PayPal Window const emailInput = Selector('#email'); const passwordInput = Selector('#password'); const acceptAllButton = Selector('#acceptAllButton'); const nextButton = Selector('#btnNext'); const loginButton = Selector('#btnLogin'); const consentButton = Selector('#consentButton, [data-test-id="continueButton"]').filterVisible(); const submitButtonInitial = Selector('[data-testid="submit-button-initial"]');
const submitWithPaypalButton = async (ppmu = false) => { const paypalIframeSelector = ppmu ? ppmuPaypalIframe : paypalIframe; await t .switchToIframe(paypalIframeSelector) .hover(payWithPaypalButton) .click(payWithPaypalButton) .wait(500); };
const paypalLogin = async () => { await t .typeText(emailInput, '', { timeout: 30000 }) .click(nextButton) .typeText(passwordInput, '') .click(loginButton); };
const completePaypalMiniWindow = async ({ shouldLogin = true, oneTimePayment = false } = {}) => { if (shouldLogin) await paypalLogin();
// closes the cookie banner if (await acceptAllButton.visible) { await t.hover(acceptAllButton).click(acceptAllButton); }
const continueButton = oneTimePayment ? submitButtonInitial : consentButton; // const paymentOptions = Selector('#paymentMethod, [data-testid="stacked-payment-options"]').filterVisible();
await t.hover(continueButton).click(continueButton); };
fixture('Verify PayPal Payments') .page('https://www.staging-change.org/') .httpAuth(httpAuthCredentials);
test('Promote with PayPal', async () => { await t .navigateTo('/p/asdf-stgaqaoppscore8/sponsors/new?country_code=CA&lang=en-CA') .expect(Selector('.js-payment-form').visible) .ok() .typeText(Selector('[data-testid="payment-form-amount-input"]'), '30', { replace: true }) .click(Selector('[data-testid="payment-option-button-paypal"]'));
await t .expect(Selector('[data-testid="input_email"]').visible) .ok() .typeText(Selector('[data-testid="input_email"]').filterVisible(), emailAddress) .typeText(Selector('[data-testid="input_confirmation_email"]').filterVisible(), emailAddress) .typeText(Selector('[data-testid="input_first_name"]'), 'first') .typeText(Selector('[data-testid="input_last_name"]'), 'last'); await submitWithPaypalButton();
// PayPal Window await completePaypalMiniWindow(); });
Your complete configuration file
{ "browsers": ["chrome:headless:emulation:device=iPhone X"], "src": "./tests/**/*.js", "clientScripts":[ { "module":"axe-core/axe.min.js" } ],
"assertionTimeout": 15000, "ajaxRequestTimeout": 40000, "pageLoadTimeout": 30000, "selectorTimeout": 15000,
"disableMultipleWindows": false,
"quarantineMode": false, "skipJsErrors": true,
"disablePageCaching": true,
"reporter": [ { "name": "xunit", "output": "artifacts/test-results/results.xml" }, { "name": "spec" } ],
"screenshots": { "fullPage": true, "takeOnFails": true, "pathPattern": "${TEST_ID}/${RUN_ID}_${FILE_INDEX}.png", "path": "artifacts/screenshots", "thumbnails": false } }
Your complete test report
-
The iframe in which the test is currently operating is not visible anymore.
Browser: Chrome 99.0.4844.51 / macOS 10.15.7 Screenshot: /***/screenshots/test-1/_errors/1.png
38 | 39 | if (shouldLogin) await paypalLogin(); 40 | 41 | // closes the cookie banner > 42 | if (await acceptAllButton.visible) { 43 | await t.hover(this.acceptAllButton).click(this.acceptAllButton); 44 | } 45 | 46 | const continueButton = oneTimePayment ? submitButtonInitial : consentButton; 47 | // const paymentOptions = Selector('#paymentMethod, [data-testid="stacked-payment-options"]').filterVisible(); 48 | at <anonymous> (/***/support/page_objects/paypalWindow.js:42:31) at asyncGeneratorStep
(//support/page_objects/paypalWindow.js:4:249) at _next (//support/page_objects/paypalWindow.js:4:587)
Screenshots
No response
Steps to Reproduce
- Use provided httpAuth credentials, and own PayPal sandbox account
- Run the test
TestCafe version
1.18.5-rc.1
Node.js version
16.13.1
Command-line arguments
testcafe chrome -u
Browser name(s) and version(s)
Chrome 99.0.4844.51
Platform(s) and version(s)
MacOS Big Sur - 10.15.7
Other
No response
Thanks for opening this bug Rob. We were also struggling with PayPal and TestCafe too. No blaming at all we all have bugs but it's the second time we're having issues with both (see that which has been closed by the way).
Hi @aurelienlair
Once we have any news we will update this thread.
This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.
We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.