groovy - 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.
解决方案
我最近在将现有项目打开到 intellij 时遇到了类似的问题,它混合了 groovy 和 java。Intellij 只识别 java 源文件夹,所以我不得不修改项目以使用 src/main/groovy 文件夹。您是否查看过您正在使用的任何 ide 的项目设置?
推荐阅读
- reactjs - 如何更新使用两个上下文消费者的组件的状态
- javascript - FileReader 删除多个文件时只读取一个文件
- ruby-on-rails - 急切加载活动存储附件仍然执行额外的查询和元请求
- actionscript-3 - 如何在数组中随机调用特定位置的 2 个值 flash
- blazor - 如何在 Blazor 托管应用程序中将数据从客户端传递到服务器
- javascript - 使用 ChartJS 时多个数据集不起作用
- android - android:style 不适用于 xml 布局
- spring-data - Spring Data R2DBC - 没有考虑背压?
- python - Python 3:如何使用 json 变量自动创建索引并发送到 Elasticsearch?
- python-3.x - Python:关闭一个pyglet窗口