Model component of Geb is not recognised

132 views
Skip to first unread message

Sushant Tambare

unread,
Apr 26, 2015, 11:59:37 AM4/26/15
to geb-...@googlegroups.com
Hi

I am trying to use Module to define menu elements in my UI so that it will be available across all other pages. Following this one - github.com/geb/geb-example-gradle

When I compile or run my code, it give module element is not imported or class is not defined errors. 

E.g.
MenuModule extends Module
-- static content = { menu $("#menu") }
HomePage
-- static content = { menus MenuModule }

Here in HomePage menus gives error. Can anyone give me explanation how this works?

Thanks 
Sushant

Pierre HILT

unread,
Apr 26, 2015, 1:52:19 PM4/26/15
to geb-...@googlegroups.com

Hello,

Your contents are not written properly.

It should be:

static content = { myModule { module MyModule } }


-- static content = { menu { $("#menu") } }

Best regards,

Pierre

--
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/5ec8b4f3-75d8-421d-b10c-24ad2009a499%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sushant Tambare

unread,
Apr 26, 2015, 1:55:17 PM4/26/15
to geb-...@googlegroups.com
Hi
Thanks for reply.. Yes  I mentioned what you have told... 

static content = { myModule { module MyModule } } - module**  in this statement itself is complaining about importing class. 
Sorry my mistake didn't include that before.

~
Sushant

Marcin Erdmann

unread,
Apr 26, 2015, 5:43:11 PM4/26/15
to geb-...@googlegroups.com
Hi Sushant,

What exactly is the code you tried and the error/exception you got? Please paste all classes/scripts in whole, describe how you run them, etc. If you want anybody to be even able to help you then you'll need to be more precise with your questions. Same applies to the other question you asked recently in this list.

Marcin

Sushant Tambare

unread,
Apr 27, 2015, 12:26:59 AM4/27/15
to geb-...@googlegroups.com
Hi Macin

I am new to all the technologies including groovy, gradle, Selenium and Geb. I am Java developer. I found Geb logical to put automation test so wanted to use it, but it seems learning curve is really hard :(

I am attaching whole project here.. I have changed names on div and passwords due to privacy of a company. 

I am using Intellij Idea to run all test cases. During compile time, I don't get any errors which I have mentioned in both posts. I get errors during runtime. 

You can check files AddTabSpec.groovy where I have used both Module as well as CreateForm.ItemName - both these give me errors. 

Now if I use simple itemName { $('#create-form #item-group input[name=itemName]')}, this works fine. 

#3 issue: I am using RIA i.e. Ajax based logic so I wait for itemName to be visible using this WebDriverWait wait = new WebDriverWait(driver, 30);
    WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("itemName")));

as well as tried using WaitFor(30){ $('#create-form #item-group input[name=itemName]').displayed }, it gives error that "Element is not currently visible and so may not be interacted with". 

Here is stack Trace for #3 issue:
Element is not currently visible and so may not be interacted with
Command duration or timeout: 65 milliseconds
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'Sushants-MacBook-Pro.local', ip: '192.168.1.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10', java.version: '1.8.0_25'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=37.0.2, platform=MAC, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: a1a28182-1fa2-2f43-acca-8413d7167054
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 65 milliseconds
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'Sushants-MacBook-Pro.local', ip: '192.168.1.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10', java.version: '1.8.0_25'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=37.0.2, platform=MAC, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: a1a28182-1fa2-2f43-acca-8413d7167054
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
	at org.openqa.selenium.remote.RemoteWebElement.clear(RemoteWebElement.java:113)
	at geb.navigator.NonEmptyNavigator.setInputValue(NonEmptyNavigator.groovy:706)
	at geb.navigator.NonEmptyNavigator.setInputValues_closure42(NonEmptyNavigator.groovy:684)
	at groovy.lang.Closure.call(Closure.java:423)
	at groovy.lang.Closure.call(Closure.java:439)
	at geb.navigator.NonEmptyNavigator.setInputValues(NonEmptyNavigator.groovy:683)
	at geb.navigator.NonEmptyNavigator.propertyMissing(NonEmptyNavigator.groovy:574)
	at geb.content.PageContentSupport.propertyMissing(PageContentSupport.groovy:74)
	at geb.Page.propertyMissing(Page.groovy:77)
	at geb.Browser.propertyMissing(Browser.groovy:217)
	at geb.spock.GebSpec.propertyMissing(GebSpec.groovy:62)
	at AddTabSpec.AddTab friend will pay(AddTabSpec.groovy:21)
Caused by: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'Sushants-MacBook-Pro.local', ip: '192.168.1.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10', java.version: '1.8.0_25'
Driver info: driver.version: unknown
	at <anonymous class>.fxdriver.preconditions.visible(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdr...@googlecode.com/components/command-processor.js:9587)
	at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdr...@googlecode.com/components/command-processor.js:12257)
	at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdr...@googlecode.com/components/command-processor.js:12274)
	at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdr...@googlecode.com/components/command-processor.js:12279)
	at <anonymous class>.DelayedCommand.prototype.execute/<(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdr...@googlecode.com/components/command-processor.js:12221)

 Thanks
Sushant
automation-test-geb.zip

Sushant Tambare

unread,
May 3, 2015, 10:13:28 PM5/3/15
to geb-...@googlegroups.com
Hi Marcin 

Can you clear my points please?

Thanks
Sushant
: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10', java.version: '1.8.0_25'
Driver info: driver.version: unknown
	at <anonymous class>.fxdriver.preconditions.visible(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdri...@googlecode.com/components/command-processor.js:9587)
	at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdri...@googlecode.com/components/command-processor.js:12257)
	at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdri...@googlecode.com/components/command-processor.js:12274)
	at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdri...@googlecode.com/components/command-processor.js:12279)
	at <anonymous class>.DelayedCommand.prototype.execute/<(file:///var/folders/sk/4g40y3ld47d6_sdvmsc8n70m0000gn/T/anonymous3647467242040651644webdriver-profile/extensions/fxdri...@googlecode.com/components/command-processor.js:12221)

Chung Beverly

unread,
May 5, 2015, 1:18:04 PM5/5/15
to geb-...@googlegroups.com
I'll try to help a bit, if I can.

I'm not sure what your page is doing when you try to interact with elements, but you can use the setting of the wait parameter so you have:
  createForm(wait: true) { $('#create-form') }

Your stacktrace shows: at AddTabSpec.AddTab friend will pay(AddTabSpec.groovy:21) - but I don't see this method.

I don't see the use of any Modules in AddTabPage.

I see NavigationModule has content defined, but no base content. This is fine. But, if at AddTabSpec line 13 you're meaning to click() on addTabLink, you'll have to do navigation.addTabLink.click(), instead.

You may want to start off AddTabSpec with a "at UserHomePage" in a given: block in "go to AddParty"()
  given:
    at UserHomePage

  when:
    navigation.addTabLink.click()
    ...

Hope this helps.

--Chung

Sushant Tambare

unread,
May 5, 2015, 11:31:35 PM5/5/15
to geb-...@googlegroups.com
Hi Chung

Thanks a lot... yes I also discovered the same with NavigationModule by trial and error :) . Yes what you have mentioned works for module. I want to update the documentation for same. How Java Or any other programming language have proper in depth documentation. Same way I want to update geb document. This way for new people it will help. 

For element interaction i.e. exception of interaction, I used waitFor at least for 90 seconds and still the same. Here in this page, I am cloning that form and making it visible after few ajax calls. But I have seen that it takes less than 1 second to finish all my ajax calls. I see on firefox my page with all these elements visible to my eyes. Now question is why geb or internally Selenium does not get these elements to interact even after 90 seconds? 


Just to update: I am running this as Junit gradle tests. My application runs on tomcat i.e. both are on different JVM. 

Thanks again
Sushant

Brian Kotek

unread,
May 6, 2015, 11:47:20 AM5/6/15
to geb-...@googlegroups.com
On Tue, May 5, 2015 at 11:31 PM, Sushant Tambare <sushant...@gmail.com> wrote:
I want to update the documentation for same. How Java Or any other programming language have proper in depth documentation. Same way I want to update geb document. This way for new people it will help. 

For an open-source project maintained by essentially one person, I think t
he documentation for Geb is actually very good.​
​ Please just keep in mind that most of this is done by one person, so we should all really be praising Marcin (and Luke before him) for the work they've done. :-)

Thanks,

Brian


Sushant Tambare

unread,
May 6, 2015, 2:05:13 PM5/6/15
to geb-...@googlegroups.com
Hi Brian

Yeah its really good. I am thankful for bringing this framework. In fact I want to contribute to documentation and source code once I start understanding this framework and usage. 

~
Sushant

Sushant Tambare

unread,
May 7, 2015, 12:19:31 PM5/7/15
to geb-...@googlegroups.com
Hi Chung/All

Your solution of using wait:true worked for me. I don't know how all these things work internally and I am interested to know how syntax and structure works for Geb. 

Thanks
Sushant
Reply all
Reply to author
Forward
0 new messages