Hi Brett,

You are correct in thinking that the problem is most likely upstream of Geb
and Gecko is either not opening the new window or reporting that no new
window has been opened. Let's try to find what exactly the problem is.

Some questions:
1. You said you recently upgraded the stack. Did the code in question used
to work before? If so, which versions of libraries in the stack did it work
on?
2. You said that changing the target of the link makes the test pass (I
find it surprising that changing the target has an influence on the
outcome) but what about leaving the target as is and changing the href? I
have a suspicion that the behaviour you're seeing has something to do with
using # as href because clicking on a link like that will not load/reload
the url in the browser.
3. Do you see the new window opened if you put a breakpoint at
https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/Browser.groovy#L828
and run the test?

On Fri, Mar 23, 2018 at 12:23 AM, Brett Randall <[email protected]> wrote:

> Cross-posted to SO: https://stackoverflow.com/questions/49440479/
> withnewwindow-throws-nonewwindowexception-for-click-of-href-target-blank
>
> Recently upgraded testing-stack:
>
> - Selenium 3.11.0
> - Gecko Driver 0.20.0
> - Geb 2.1
>
> I have an `index.html` with this link:
>
>
> <div><a id="openNewChat" href="#" target="_blank">Open new chat</a></div>
>
>
> Manual browsing with current Chrome or Firefox on MacOS, clicking this
> link opens a new tab containing the same page.
>
> With this Geb code:
>
>
> withNewWindow({ $('#openNewChat').click() }, close: false) {
>        $('#username').value('a')
>        $('#message').value('xxx')
>        $('#btnSend').click()
>        otherBrowser = getCurrentWindow()
>      }
>
>
>
> ... Geb throws a NoNewWindowException every execution.  If I change the
> target to target="otherBrowser", the exception is not thrown, and the test
> passes.
>
> Is Geb/WebDriver/Gecko/Selenium doing something wrong here?  I'm guessing
> that the answer is going to come back that this is a problem upstream of
> Geb, and that Geb is just seeing the driver report the same set of
> availableWindows before and after the click.
>
>
> Brett
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/geb-user/35ac97e3-f465-498e-b90c-f26453a29558%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/35ac97e3-f465-498e-b90c-f26453a29558%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/CA%2B52dQRq8L_erDYMekP%3D%2BZRJ%3DbKgbfsHAQhrVP-aAU-ngSszwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to