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

Access popup page #4468

Closed
JullianeFreitas opened this issue Jun 14, 2019 · 10 comments
Closed

Access popup page #4468

JullianeFreitas opened this issue Jun 14, 2019 · 10 comments

Comments

@JullianeFreitas
Copy link

JullianeFreitas commented Jun 14, 2019

Hey everybody,

I've been studying cypress and doing some tests but I have a doubt and cant find a answer.

I have a HTML page and a button who open a popup page:

<input type="button" id="Mybutton" value="Abrir Popup" onClick="javascript:createPopup('')">
function createPopup(title){
	var popup = open("", title, "width=300,height=200");
	var txt = popup.document.createElement("TEXTAREA");

	popup.document.body.appendChild(txt);
}

How can I access the popup page and the components?

@jennifer-shehane
Copy link
Member

@JullianeFreitas For using window.open, we recommend stubbing window to ensure the method is called appropriately as shown in this recipe: https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/stubbing-spying__window/cypress/integration/window-stubbing.spec.js

As for accessing the new window afterward - you would have to have some route to visit to see these components - maybe already have an html page that you pass to open that you can then independently call cy.visit() on to test?

Also, try checking out our community chat - it can be helpful for debugging things like this.

@zackgatt
Copy link

Is there a way to close the popup after stubbing it?

@beekimrj
Copy link

@jennifer-shehane , i have similar question, hope you can help me
i have a form containing check-in and check-out date, and a search button, when i select both dates, and click search, it opens new tab and its url contains booking website with check-in and check-out date , now how to check if url have selected dates

@jennifer-shehane
Copy link
Member

@beekimrj Issues in our GitHub repo are reserved for potential bugs or feature requests. This issue will be closed since it appears to be neither a bug nor a feature request.

We recommend questions relating to how to use Cypress be asked in our community chat. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.

@zuhi28
Copy link

zuhi28 commented Jul 8, 2020

Hey @JullianeFreitas just wanted to check if you got any resolution on this? I am also facing same issue

@kevinbarabash
Copy link

@jennifer-shehane is there a way to turn this into a feature request? I'd like to be able to use cypress.io for testing third-party login flows such as Google OAuth which uses a popup window for users to authenticate.

@sugu-pb
Copy link

sugu-pb commented Oct 9, 2020

Hi @jennifer-shehane, I have spent a whole good week in investigating how can I automate Google Pay integration in our checkout but couldn't find a solution as with Google Pay I need to have a valid googlePayToken to make API calls, and I can only get token if I hit pay button on Google Pay pop-up.
I understand you guys don't encourage people to automate 3rd party application, but I feel that's a very generic approach. Every project is different with different needs, so even if it is not recommended, there should be a way to automate 3rd party pop-ups/authentication etc.
Also, I would really appreciate if you or anyone else can suggest me a way of automating Google Pay with Cypress.

@Duncan00
Copy link

Duncan00 commented Oct 9, 2020

We got similar problem also. In our UI flow, we have a popup window to do payment.
Then there is a postMessage back to main window so that we can know the payment process is finished, and then we can continue our process in main window.

It would be nice if we can have a way to do it by Cypress.

@mightymatth
Copy link

Another interested buddy for accessing popups in cypress tests (login with Google, login with Facebook, login and signing transactions with Arkane). Does anyone have something to recommend rather than mocking these things?

@janat08
Copy link

janat08 commented Nov 21, 2021

I found auto stub plugin which supports version 5 cypress. Perhaps that could be offered as alternative after upgrading it. You could also provide mocks of popular derives for login and payment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants