无法在“Cucumber-Groovy-geb-maven”项目中启动Web浏览器

时间:2016-03-17 12:47:55

标签: java maven grails groovy

这是Vinayak。我创建了Cucumber-Groovy-geb-maven项目。我已经完成了门户网站上提供的设置,但在启动浏览器时遇到了问题。我无法找到解决方案。有人可以帮助我吗?

RunCuketest.groovy

package runner

import org.junit.runner.RunWith;
import org.junit.runner.*;
import cucumber.api.junit.*;
import org.junit.*;
import cucumber.api.junit.Cucumber;
import cucumber.api.CucumberOptions;
import cucumber.runtime.junit.*;
import cucumber.runtime.*;
import cucumber.api.*    
import org.junit.Test


@RunWith(Cucumber.class)
@CucumberOptions (
    features = ['src/test/resources/features/'],
    tags = ['~@wip'],
    format =          ['pretty','html:build/reports/cucumber','junit:build/cucumber.xml'],
    glue = [ 'src/test/groovy/stepDefinition/']

 )
 public class RunCukeTest {

 }

GebConfig.groovy

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.firefox.FirefoxDriver;
import geb.Browser;

def browser = new Browser(driver: new FirefoxDriver())
/*
  driver = {

  def driverInstance = new FirefoxDriver();
  driverInstance.manage().window().maximize();
  driverInstance
}*/


baseUrl = "http://gebish.org"

baseNavigatorWaiting = true

env.groovy

package stepDefinition

import geb.*
import geb.Browser
import geb.binding.BindingUpdater

import static cucumber.api.groovy.Hooks.After;
import static cucumber.api.groovy.Hooks.Before;

Before() {
   bindingUpdater = new BindingUpdater(binding, new Browser(baseUrl :        "http://newtours.demoaut.com/"))
  //bindingUpdater = new BindingUpdater(binding, new Browser())
  bindingUpdater.initialize()
}

After() {
 bindingUpdater.remove()
}

定义文件

package stepDefinition

import geb.*
import geb.Browser;
import geb.navigator.factory.*;

import cucumber.api.groovy.EN.*;
import cucumber.api.groovy.*;
import geb.*;

this.metaClass.mixin(cucumber.api.groovy.EN);
this.metaClass.mixin(cucumber.api.groovy.Hooks);
this.metaClass.mixin(geb.Browser);

import pages.*;
import pages.mercurySearch;


Given(~/^I am at the mercury tours home page$/) { ->
     to mercurySearch    
     at mercurySearch
}

When(~/^I enter "(.*?)" in userName field$/) { String sUName ->
    mercurySearch.txtUserName.value(sUName)
}

And(~/^I enter "(.*?)" in password field$/) { String sPwd ->
    mercurySearch.txtPassWord.value(sPwd)
}

And(~/^I click on SignIn button$/) { ->
   mercurySearch.btnSignIn.click()
}

我做错了什么?

感谢.....

0 个答案:

没有答案