groovy - GEB + Spock:没有方法签名
问题描述
我正在尝试用 GEB 和 Spock 编写一个简单的测试。以下是页面和规格测试:
页
import geb.Page
class DashboardPage extends Page {
static url = "?root=dashboard"
static at = { pageTitle.text() == "Dashboard Content Area" }
static content = {
pageTitle(wait: 25) { $("div#content-view-title>h1") }
leaderBoardPeriodCombo { $("#leaderboardPeriod") }
//manualsMenu { module(ManualsMenuModule) }
}
def selectLeaderBoardPeriod(periodValue) {
leaderBoardPeriodCombo.value(periodValue)
}
}
规格测试:
import geb.spock.GebSpec
import pages.DashboardPage
class LeaderboardSpec extends GebSpec {
def "change LeaderBoard type value"() {
when: to DashboardPage
then: at DashboardPage
when: DashboardPage.selectLeaderBoardPeriod("monthly")
then: at DashboardPage
}
}
但我收到以下错误:
groovy.lang.MissingMethodException:
No signature of method: static pages.DashboardPage.selectLeaderBoardPeriod() is applicable for argument types: (java.lang.String) values: [monthly]
Possible solutions: selectLeaderBoardPeriod(java.lang.String)
at specs.LeaderboardSpec.change LeaderBoard type value(LeaderboardSpec.groovy:13)
Results :
Tests in error:
LeaderboardSpec.change LeaderBoard type value:13 MissingMethod No signature of...
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
selectLeaderBoardPeriod 的签名它有一个参数。我试图将类型明确定义为 String 但我得到了同样的错误。
有人能发现我做错了什么吗?
先感谢您。
此致
解决方案
您的规格需要类似于:
class LeaderboardSpec extends GebSpec {
def "change LeaderBoard type value"() {
when:
def page = to DashboardPage
and:
page.selectLeaderBoardPeriod("monthly")
then:
at DashboardPage
}
}
推荐阅读
- applescript - 如何在活动窗口中打开不同的文件,并使用 AppleScript 提供扩展名
- ffmpeg - 如何让 FFMPEG 使用 libx264 对 H264 进行编码?
- jquery - Laravel - 如果更改下拉列表中的语句失败
- json - Scala中的HTTP Post请求使用JSON正文中的变量
- excel - VBS 脚本不会运行宏并保存
- android - Android Kotlin 与屏幕开/关 intentfilter 共享数据
- python - 如何从层中分配变量?
- excel - 将 Powerpoint 表格中的文本导入 Excel
- javascript - Javascript 数据类型:BigInt vs Number
- java - 如何以编程方式将文本写入 Flink 套接字?