handling random popups

23 views
Skip to first unread message

medv...@gmail.com

unread,
Sep 23, 2021, 6:38:09 AM9/23/21
to Geb User Mailing List
hi,
is there a way to handle random popups in geb?

I found this https://www.vinsguru.com/selenium-webdriver-how-to-handle-annoying-random-popup-alerts/  but have no idea how to build this into the pages?

I need to click away a random popup like this:
popup.jpg

Thank you!

Jeremy Cattau

unread,
Sep 23, 2021, 7:44:03 AM9/23/21
to geb-...@googlegroups.com
Do you need popups enabled at all?  If not, just pass in the capability to the browser to prevent popups.  In chrome it's
options.addArguments("--disable-popup-blocking")

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/a6d63fb1-b01b-474d-b5db-f5f69e38abd5n%40googlegroups.com.

medv...@gmail.com

unread,
Sep 24, 2021, 2:43:37 AM9/24/21
to Geb User Mailing List
yes, I need popups.

in the meantime I got parameters from dev, which I need to pass to every page like "?qualtrics=notest&stage=prod", so every page needs to be called like that: http://test.abc.com/?qualtrics=notest&stage=stage

how do I build this into the framework? 

is there central place where I can add arguments/parameters like that to all current urls?

thank you!

Marcin Erdmann

unread,
Sep 28, 2021, 4:52:49 PM9/28/21
to geb-...@googlegroups.com
You would need to add a base page class which all of your pages would extend from and which would have the following method:

    @Override
    void to(Map params, UrlFragment fragment, Object... args) {
        super.to([qualtrics: "notest", stage: "prod"] + params, fragment, args)
    }

medv...@gmail.com

unread,
Sep 30, 2021, 6:04:25 AM9/30/21
to Geb User Mailing List
thank you Marcin!

I added your code like this as I could convince devs to only use one parameter: ?qualtrics=notest

geb.jpg

it does not work. does this really add ?qualtrics=notest to the url when the page is loaded?

I added the section above to all pages in the framework, but I do not see in the logs if pages are called each time with the parameter ?qualtrics=notest.

could you please help me?

Marcin Erdmann

unread,
Sep 30, 2021, 7:03:56 AM9/30/21
to geb-...@googlegroups.com
On Thu, Sep 30, 2021 at 11:04 AM medv...@gmail.com <medv...@gmail.com> wrote:
it does not work. does this really add ?qualtrics=notest to the url when the page is loaded?

Can't you put a breakpoint in the test after you navigate to a page with the change I suggested, execute the test and when the breakpoint is reached check the url in the browser? This will only work if you navigate to the page using the to() method, not when you navigate by clicking in the app...

medv...@gmail.com

unread,
Sep 30, 2021, 1:50:16 PM9/30/21
to Geb User Mailing List
"This will only work if you navigate to the page using the to() method, not when you navigate by clicking in the app"

Exactly that is my problem, only some pages get this parameter added to the url during execution. How can I get this parameter for every page?

Thank you!

Marcin Erdmann

unread,
Oct 1, 2021, 3:33:22 AM10/1/21
to geb-...@googlegroups.com
As far as I know there is no way to do that. The urls generated by the app themselves would need to be adding that parameter from urls that already have that. Cannot the devs provide you with a way to disable that behaviour in a more persistent way? One things that comes to mind is to persist that it should be disabled in a cookie or http session as soon as you go to a page with that parameter... Cause really you don't have control over urls the app itself sends you to...

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages