Is that test passing locally on MacOS for you using the same version of selenium, gecko and Firefox? I'm wondering if the issue is in running it in headless mode. You did not mention in your original post that the tests are run in headless mode on Travis.
On Tue, Mar 27, 2018 at 3:42 AM, Brett Randall <[email protected]> wrote: > Hi Marcin, thanks for the reply. > > For 1 - it's a little hard to compare what worked with what did not, > because I was trying to move the tests to another platform that was quite > different to where the tests were working: > > Working: MacOS, geckoDriverVersion = 0.17.0 (macos), seleniumVersion = > 3.4.0, gebVersion=1.1.1 > New Environment: Linux Ubuntu Trusty, headless on > Travis, geckoDriverVersion = 0.20.0, seleniumclick target that opens the > new windowVersion=3.11.0, gebVersion=2.1 > > The tests as they were hard-coded the Gecko driver to MacOS ... having > fixed that, the tests did not run well on Travis. In addition to the > upgrades, I added a Selenium setHeadless(true) for the Firefox driver. > > For 2 - changing the target certainly seemed to work. With either > "_blank" or "anythingelse" when clicking the link in a manual browser, a > new tab opened fine. For some reason in headless/test-run mode it did not > like the _blank. I'll see if I can come up with something different for > the href="#", but since the link is just a JavaScript click target, I don't > really see a problem with that link. > > For 3 - I can't set a breakpoint in Travis at the moment. I might try on > a non-Travis Linux environment to do that. What I can say is that there > are either 0 or >1 windows created based on the code - those are the only > possibilities. Unfortunately I'm not getting the NoNewWindowException > string message at the moment to clarify which it is, but I guess 0. > > Brett > > On Friday, March 23, 2018 at 8:49:11 PM UTC+11, Marcin Erdmann wrote: >> >> 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/sr >> c/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/ms >>> gid/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/ms > gid/geb-user/e7124810-9fb4-4004-80e7-a0ff1f3512d6%40googlegroups.com > <https://groups.google.com/d/msgid/geb-user/e7124810-9fb4-4004-80e7-a0ff1f3512d6%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%2B52dQTZWGkK5zYLufeC0bC%3D_hnuNm%2BRYz9Aaxx0qp44_8T3bQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
