It turns out a better work-around, since I only want to reference the first 
table, is to use
('table.GNItemTable',0 ).$('thead tr th')
which is a better fit for my needs, as I want to reference only the first 
table.

Still, any reason why the chaining form table.$('thead tr th') doesn't work?

On Monday, August 7, 2017 at 11:25:43 PM UTC-4, Mark wrote:
>
> This code is a pared-down version of some web scraping to isolate errors 
> I'm experiencing in a minimal implementation.  I've narrowed it down to the 
> difference between doing Navigator.$(selector)  and  $(full selector).   
>
> import geb.Browser
> System.setProperty("webdriver.chrome.driver", 
> 'c:\\webdrivers\\chromedriver.exe')
> Browser.drive {
>   go "https://www.uline.com/Product/GuidedNav?t=184360&dup=over"; // direct to 
> Shipping Boxes
>   assert title == 'ULINE - Shipping Boxes'
>   while (true) {
>     def table = $('table.GNItemTable')
>     assert table!=null && table.size()>0    
>     // def theader = table.$('thead tr th')  // usually fails after one page
>     def theader = $('table.GNItemTable thead tr th')  // never fails
>     def next = $('a.EnabledLink', text: 'Next>')
>     if (next == null || next.size() == 0) break;
>     next[0].click()
>   }
> }
>
> When I use method chaining; table.$('thead tr th') the code will fail with an 
> ElementReferenceException usually on loading 2nd page.  When I use the full 
> selector $('table.GNItemTable thead tr th') it runs consistently flawless.
>
>

-- 
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/29758f8a-708b-4337-9d3c-0fcb1a0b8060%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to