static url = "manual"
String convertToPath(Manual manual) {
"/${manual.version}/index.html"
}As I see it, version is an surfix of static url, which is added to base page.currentUrl == "http://www.gebish.org/manual/0.9.3/index.html"
--
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/52970a34-0fc3-4766-9469-b9e13892a27e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
changing static fields from a constructor is almost never a good idea.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/CA%2B52dQSw57YsA7iYEQ-Ld26tGq6omQ6ckAsNrx7LjoZE8i7g4A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/EF6AF478-A08A-4456-BC53-EB5CDFEE68BC%40mavericklabel.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/CA%2B52dQSK%2BX9kHOVb7uG%2B19v%2BnxQY8wG%3Dzj7C-McdjRCcuKV75Q%40mail.gmail.com.
Hi Jeff, Marcin:
First of all, please forgive me for not responding sooner.
I took Marcin advice to create enum class.
But I had meet some problems.
First of them is when I'm doing Maven test run, it shrieks that abstract methods cannot be inside non abstract class (In this case enum is not such class) - build fails.
But when running the same scenario straight from IDEA, there are no such errors.
Second, I have many pages with languages, so basicly, now I'm creating enum 'sub' class inside each of page files.
(This connects to one more issue, but it is probably connected with groovy, and my lack of understanding, what and how i would like to do:
basicly, I tried to create interface which would implement enum, unfortunately in this case declared abstract method inside interface is not visible for enum :()
Is it a good approach? Or should I include it in external enum class, with various names of each enum coresponding to proper page?
Lastly, I tried to create one single enum class, which would take values from xml/json file but slurpers and page instance called from browser return me an error (static enum cannot use non static variables/methods)
enum Language{
PL{
String getTitle(){'Historia'}
String getPath(){'historia'}
String getPageParent(){'o-nas'}
},
EN{
String getTitle(){'History'}
String getPath(){'history'}
String getPageParent(){'about-us'}
},
DE{
String getTitle(){'Geschichte'}
String getPath(){'geschichte'}
String getPageParent(){'uber-uns'}
}
abstract String getTitle()
abstract String getPath()
abstract String getPageParent()
} interface Gatherable{
abstract String getTitle()
abstract String getPath()
abstract String getPageParent()
}
enum Language implements Gatherable{
PL{
String getTitle(){'Historia'}
String getPath(){'historia'}
String getPageParent(){'o-nas'}
},
EN{
String getTitle(){'History'}
String getPath(){'history'}
String getPageParent(){'about-us'}
},
DE{
String getTitle(){'Geschichte'}
String getPath(){'geschichte'}
String getPageParent(){'uber-uns'}
}
}
package helpers
import geb.Browser
class Languages {
def browser = new Browser()
static String xmlFile = new File( "." ).getCanonicalPath().replace("\\","/") + "/src/test/xmlFiles/Languages.xml"
static def xml = new XmlSlurper().parse(xmlFile)
static String query
String pageInstance = browser.page
enum Language {
EN{
String getTitle() {
query = 'language.en.' + pageInstance + '.title'
Eval.x(xml, "x.$query")
}
String getPath() {
query = 'language.en.' + pageInstance + '.path'
Eval.x(xml, "x.$query")
}
},
DE{
String getTitle() {
query = 'language.de.' + pageInstance + '.title'
Eval.x(xml, "x.$query")
}
String getPath() {
query = 'language.de.' + pageInstance + '.path'
Eval.x(xml, "x.$query")
}
},
PL{
String getTitle() {
query = 'language.pl.' + pageInstance + '.title'
Eval.x(xml, "x.$query")
}
String getPath() {
query = 'language.pl.' + pageInstance + '.title'
Eval.x(xml, "x.$query")
}
}
abstract String getTitle()
abstract String getPath()
}
}
--
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/d0377d9e-05fc-40df-aa87-8b1eeeceb497%40googlegroups.com.