gpt4 book ai didi

module - 如何在不单独声明每个元素的情况下使用 Spock 一次验证 Geb 模块的全部内容?

转载 作者:行者123 更新时间:2023-12-02 04:33:13 24 4
gpt4 key购买 nike

我有一个模块,其中为我正在使用的网页上的每个元素定义了内容:

package com.abc.modules

import geb.Module

class Member extends Module {
static content = {
// Member fields
mbrID {$("div.subject-details div.memberDetails input.projMbrId")}
mbrName {$("input.projMbrName")}
mbrRegion {$("select.projMbrReg")}
mbrAdd1 {$("input.projMbrAdd1")}
mbrAdd2 {$("input.projMbrAdd2")}
mbrAdd3 {$("input.projMbrAdd3")}
mbrCity {$("input.projMbrCity")}
mbrState {$("select.projMbrState")}
mbrZip {$("input.projMbrZip")}
mbrHomePhone {$("input.projMbrHomePhone")}
mbrHomePhoneExt {$("input.projMbrHomePhoneExt")}
mbrWrkPhone {$("input.projMbrWorkPhone")}
mbrWrkPhoneExt {$("input.projMbrWorkPhoneExt")}
mbrEmail {$("input.projMbrPersonalEMail")}
mbrWrkEmail {$("input.projMbrWorkEMail")}
}
}

在我的测试规范中,我断言我的模块中包含的每个元素都存在,但我知道如何做到这一点的唯一方法是单独断言每个元素:

package cmdr.ProjectCover

import com.gdit.qa.fwa.geb.cmdr.pages.HomePage
import com.gdit.qa.fwa.geb.cmdr.pages.ProjectCover
import geb.spock.GebReportingSpec

class VerifyMemberFields extends GebReportingSpec {
def setupSpec() {
// Log in to app
via HomePage
loginPage.signIn("marco", "abc123")

// Navigate to Member Page
memberPageButton.click()
}

def "Verify Member fields exist"() {
when: "User selects Member option for subject type"
at ProjectCover
projSubject.click()
projCoverMbrFields.projSubjectMbrOption.click()

then: "All expected member fields are displayed in the left panel"
assert projCoverMbrFields.mbrID.present
assert projCoverMbrFields.mbrName.present
assert projCoverMbrFields.mbrRegion.present
assert projCoverMbrFields.mbrAdd1.present
assert projCoverMbrFields.mbrAdd2.present
assert projCoverMbrFields.mbrAdd3.present
assert projCoverMbrFields.mbrCity.present
assert projCoverMbrFields.mbrState.present
assert projCoverMbrFields.mbrZip.present
assert projCoverMbrFields.mbrHomePhone.present
assert projCoverMbrFields.mbrHomePhoneExt.present
assert projCoverMbrFields.mbrWrkPhone.present
assert projCoverMbrFields.mbrWrkPhoneExt.present
assert projCoverMbrFields.mbrEmail.present
assert projCoverMbrFields.mbrWrkEmail.present
}

我想知道是否有一种方法(而不是单独断言我的模块的每个元素)一次断言模块的全部内容,这样我的特征方法就可以减少阻塞条件。

最佳答案

目前我不知道有什么方法可以做到,但是当 GEB-369 时,这将是可能的,而且相对容易。已实现。

关于module - 如何在不单独声明每个元素的情况下使用 Spock 一次验证 Geb 模块的全部内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46479173/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com