Thank you Alexander Kriegisch and Marcin Erdmann for your replies. I found
the way to do it.
Here is what I did:
0. So initially I had a Serenity+Cucumber+Java+Maven project. It's easy to
set it up just by going through Serenity documentation
<http://thucydides.info/docs/serenity-staging/#_building_serenity_projects_in_maven>
1. I found this
post: https://github.com/serenity-bdd/serenity-core/issues/941
2. Then I asked tde-desc <https://github.com/tde-desc> for some more
information (see it in the same post)
3. I added following dependencies to pom.xml file:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.13</version>
</dependency>
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-core</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
4. Added GebConfig.groovy file to src/test/resources folder. The content is
absolutely typical (taken from gebish.org) so I'm not adding it here
5. Added the following code to the class with UI step definitions:
import geb.Browser
import geb.binding.BindingUpdater
import org.openqa.selenium.WebElement
import cucumber.api.java.After
import cucumber.api.java.Before
class UiSteps {
def bindingUpdater
def browser
@Before
public void initiateAdapter(){
browser = new Browser()
bindingUpdater = new BindingUpdater(new Binding(), browser)
bindingUpdater.initialize()
}
@After
public void removeAdapter(){
bindingUpdater.remove()
}
}
6. Then I created a typical Geb page class with elements and methods
7. And added step definitions to the UiSteps class. Here is the example
import geb.Browser
import com.myproject.pages.JobsPage
@When("^.* navigate? to a job by (index|name|id) (.*)")
public void user_opens_a_job(findJobBy, identifier){
Browser.drive{
at JobsPage
switch(findJobBy){
case "index":
openJobByIndex(Integer.parseInt(identifier)) //openJobByIndex is
a method in JobsPage class
break
case "id":
*openJobById*(identifier) //openJobById is a method in JobsPage
class
break
default:
break
}
}
}
This is it. Now I'm able to run tests either through JUnit (when running
them from IDE) or from maven by "mvn verify" command (when I need to get
serenity report)
--
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/b487d443-31e9-4140-8720-6105c2caf062%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.