'moveToElement' from interaction works not as expected in Geb 1.0v

463 views
Skip to first unread message

Aleksandr Abrosimov

unread,
Nov 1, 2016, 8:17:22 AM11/1/16
to Geb User Mailing List
Hi, I'm using Geb 1.0v and faced with unexpected behavior:
 
After I apply 'moveToElement' for an element from drop down menu, it's just highlighted and nothing happen - menu doesn't fall down.
It seems like cursor hovers over menu item and takes away at once.

The same peace of code works fine for Geb 0.13.1v

Thanks,
Alex

Brian Kotek

unread,
Nov 1, 2016, 9:35:08 AM11/1/16
to Geb User Mailing List
It really depends on the menu implementation, and whether it's a standard HTML select box or some custom UI component. You may need to click on it...or you may need to inspect the live DOM to make sure that you're targeting an element that actually triggers the menu to show. 

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/ee37f351-9fcb-41ef-83a5-e14f346d4eb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcin Erdmann

unread,
Nov 1, 2016, 5:12:33 PM11/1/16
to Geb User Mailing List
Hi Aleksandr,

Can you please share your code that performs the interaction in question?

I don't think anything related to handling of mouse actions in the interact { } blocks changed between 0.13.1 and 1.0. There were some implementation changes in that area but they were released as part of 0.13.0.

Marcin

Aleksandr Abrosimov

unread,
Nov 1, 2016, 6:15:42 PM11/1/16
to geb-...@googlegroups.com
Good evening, Marcin

Here is the code which confuses me:

class DefaultTestClass {
private static Browser browser;

@BeforeClass
public static void setUp() {
ClassLoader classLoader = DefaultTestClass.class.getClassLoader();
File file = new
File(classLoader.getResource("chromedriver.exe").getFile());
System.setProperty("webdriver.chrome.driver", file.path);
browser = new Browser()
browser.driver = new ChromeDriver();
browser.baseUrl = "http://www.very.co.uk/"
browser.driver.manage().window().maximize();
}

@Test
public void start() {
Browser.drive(browser, {
to HomePage
chooseCategory('Men', 'Trainers')
at GalleryPage
})
}

@AfterClass
public static void tearDown() {
browser.quit();
}
}

class HomePage extends Page {
static url = 'http://www.very.co.uk/'
static at = {title == 'Very | Womens, Mens and Kids Fashion,
Furniture, Electricals & More!'}
static content = {
categoryByName {catName -> $("#topNav a", text: catName)}
subcatName{ catName -> $(".topNavCol a", text: catName)}
}
def chooseCategory(String category, String subCategory) {
interact {moveToElement categoryByName(category)}
subcatName(subCategory).click()
}
}


I know that current code could be refactored...but the main point is
'interact' block.
I found a workaround - replace moveToElement on clickAndHold, but
again it is not what I want.
NOTE: While you trying to reproduce it, keep mouse cursor in the
bottom of the page

Marcin, thank you in advance and I'm looking forward for a feedback

Thanks,
Alex

2016-11-01 23:12 GMT+02:00 Marcin Erdmann <marcin....@proxerd.pl>:
> Hi Aleksandr,
>
> Can you please share your code that performs the interaction in question?
>
> I don't think anything related to handling of mouse actions in the interact
> { } blocks changed between 0.13.1 and 1.0. There were some implementation
> changes in that area but they were released as part of 0.13.0.
>
> Marcin
>
> On Tue, Nov 1, 2016 at 12:17 PM, Aleksandr Abrosimov <box4...@gmail.com>
> wrote:
>>
>> Hi, I'm using Geb 1.0v and faced with unexpected behavior:
>>
>> After I apply 'moveToElement' for an element from drop down menu, it's
>> just highlighted and nothing happen - menu doesn't fall down.
>> It seems like cursor hovers over menu item and takes away at once.
>>
>> The same peace of code works fine for Geb 0.13.1v
>>
>> Thanks,
>> Alex
>>
>> --
>> 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 post to this group, send email to geb-...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/geb-user/ee37f351-9fcb-41ef-83a5-e14f346d4eb6%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Geb User Mailing List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/geb-user/oiQFSbY5OXo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> geb-user+u...@googlegroups.com.
> To post to this group, send email to geb-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/CA%2B52dQS1G3uc-_QRwyvOuAZ10D9A8mUXrW6Obf064HkCchWgSA%40mail.gmail.com.

Marcin Erdmann

unread,
Nov 2, 2016, 3:17:46 PM11/2/16
to Geb User Mailing List
I cannot explain why that code works for you with 0.13.1 and not with 1.0 but why don't you perform clicking on the subcategory inside of the interact block?

def chooseCategory(String category, String subCategory) {
    interact {
        moveToElement categoryByName(category)
        moveToElement subcatName(subCategory)
        click()
    }
}


>> To post to this group, send email to geb-...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/geb-user/ee37f351-9fcb-41ef-83a5-e14f346d4eb6%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Geb User Mailing List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/geb-user/oiQFSbY5OXo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

> To post to this group, send email to geb-...@googlegroups.com.
> To view this discussion on the web visit
--
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+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

Aleksandr Abrosimov

unread,
Nov 2, 2016, 4:04:08 PM11/2/16
to geb-...@googlegroups.com
Hi Marcin and thanks for the reply

I've tried your option, but unfortunately the result is the same(
I can not explain why ONLY moveToElement doesn't work and I feel that
I missed something important like dependency etc

I am using Java 1.8, Selenium 3.0.1, chromedriver 2.25, Geb 1.0

Marcin, did you manage to choose subcategory?
>> >> email to geb-user+u...@googlegroups.com.
>> >> To post to this group, send email to geb-...@googlegroups.com.
>> >> To view this discussion on the web visit
>> >>
>> >> https://groups.google.com/d/msgid/geb-user/ee37f351-9fcb-41ef-83a5-e14f346d4eb6%40googlegroups.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to a topic in the
>> > Google Groups "Geb User Mailing List" group.
>> > To unsubscribe from this topic, visit
>> > https://groups.google.com/d/topic/geb-user/oiQFSbY5OXo/unsubscribe.
>> > To unsubscribe from this group and all its topics, send an email to
>> > geb-user+u...@googlegroups.com.
>> > To post to this group, send email to geb-...@googlegroups.com.
>> > To view this discussion on the web visit
>> >
>> > https://groups.google.com/d/msgid/geb-user/CA%2B52dQS1G3uc-_QRwyvOuAZ10D9A8mUXrW6Obf064HkCchWgSA%40mail.gmail.com.
>> > 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 geb-user+u...@googlegroups.com.
>> To post to this group, send email to geb-...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/geb-user/CAESZyvqDobPcuQBJTqA-oPE7mqKCduxDB1Stnz9YjG_wBQBGBw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Geb User Mailing List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/geb-user/oiQFSbY5OXo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> geb-user+u...@googlegroups.com.
> To post to this group, send email to geb-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/CA%2B52dQSJ93m-W%2BmoVTpPWW4B_aMZp%2B9OZiUoOG2WqNUJGTO%3DFA%40mail.gmail.com.

Aleksandr Abrosimov

unread,
Nov 2, 2016, 5:21:11 PM11/2/16
to geb-...@googlegroups.com
The only way I managed to make moveToElement work is:

def chooseCategory(String a, String b) {
interact {
moveToElement(category(a))
}
interact {
moveToElement(subCat(b))
click()
}
}

As you can see, each moveToElement is in a separate interact block
Reply all
Reply to author
Forward
0 new messages