首页 > 解决方案 > groovy.lang.MissingMethodException when running my test

问题描述

When I attempt to run a .groovy test, the console is kicking back this error:

Caught: groovy.lang.MissingMethodException: No signature of method: GebConfig.waiting() is applicable for argument types: (GebConfig$_run_closure1) values: [GebConfig$_run_closure1@659499f1] Possible solutions: wait(), wait(long), toString(), toString(), wait(long, int), main([Ljava.lang.String;) groovy.lang.MissingMethodException: No signature of method: GebConfig.waiting() is applicable for argument types: (GebConfig$_run_closure1) values: [GebConfig$_run_closure1@659499f1] Possible solutions: wait(), wait(long), toString(), toString(), wait(long, int), main([Ljava.lang.String;) at GebConfig.run(GebConfig.groovy:28)

Process finished with exit code 1

My GebConfig.groovy is set up as follows:


    import geb.driver.BrowserStackDriverFactory
    import org.openqa.selenium.WebDriver
    import org.openqa.selenium.chrome.ChromeDriver
    import org.openqa.selenium.firefox.FirefoxDriver
    import org.openqa.selenium.remote.DesiredCapabilities
    import org.openqa.selenium.remote.RemoteWebDriver


    baseUrl = "https://ourtestingurl.com/"

    /*driver = 'chrome'
     environments {
     'chrome' {
     def chromeDriver = new File('src/test/resources/chromedriver.exe')
     System.setProperty('webdriver.chrome.driver', chromeDriver.absolutePath)
     driver = { new ChromeDriver() }
     driver.manage().window().maximize()
     }
     'firefox' {
     def FirefoxDriver = new File('src/test/resources/geckodriver.exe')
     System.setProperty('webdriver.gecko.driver', geckoDriver.absolutePath)
     driver = { new FirefoxDriver() }
     }
     }
     */
    reportsDir = new File("target/geb-reports1")

    waiting {
        timeout = 50
        retryInterval = 0.5
        slow { timeout = 52 }
        reallyslow { timeout = 80}
    }

    String USERNAME = "username";
    String AUTOMATE_KEY = "niceTry";
    String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub";
    driver = {
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("os", "Windows");
        caps.setCapability("os_version", "10");
        caps.setCapability("browser", "Chrome");
        caps.setCapability("browser_version", "75.0");
        caps.setCapability("browserstack.local", "false");
        caps.setCapability("browserstack.debug", "true");
        caps.setCapability("browserstack.selenium_version", "3.14.0");
        WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
    }

I'm at a complete loss and have spent my entire day trying to figure this out.

标签: groovygeb

解决方案


我最近在将现有项目打开到 intellij 时遇到了类似的问题,它混合了 groovy 和 java。Intellij 只识别 java 源文件夹,所以我不得不修改项目以使用 src/main/groovy 文件夹。您是否查看过您正在使用的任何 ide 的项目设置?


推荐阅读