Вопрос

I was trying to automate some functional tests using Spock (Grails app) and I'm not able to figure out how to automate the following: I need to be able to login to one Web app and click on a link (from the web app) and open a new browser window and be logged in to the second app (because they share the user credentials - they use SSO). All the functionalities I need to test are on the second web app and there is NO direct login to that app.

I was wondering if there is a way to use the current browser session (and share the cookie) between web apps.

I would appreciate any ideas.

Answer found

I have managed to find the answers to my query. As mentioned in my comments below, I used withNewWindow() method as follows:

withNewWindow({ AnchorForNewPage.click()}){ assert at(NewPage) do something and something else } Make sure that actions you perform on the second page are all within this closure, otherwise the tests will fail.

Это было полезно?

Решение

Let me quote The Book of Geb:

The geb.spock.GebSpec class will clear the cookies in the cleanup() method unless the spec is @Stepwise, in which case they are cleared in cleanupSpec() (meaning that all feature methods in a stepwise spec share the same browser state).

Not sure will it do for SSO and session sharing between two web-apps, but you may give it a try. Just keep the test steps requiring shared session as fixture methods in single Specification class.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top