geb - Geb If Else 或尝试捕获处理
问题描述
我是 Geb 语音测试的新手,我有一个 ui 发送消息和接收文本或电子邮件的测试,我有一个获取发送的电子邮件/文本的 api 调用,我需要使用该响应并继续进行 UI 测试。但是该响应已过期,因为 api 速度很快,并且它获取了先前发送的消息(在我的 ui 发送该电子邮件/文本之前)并且最后发送的消息使之前的消息过期。所以我的问题是,如果消息已过期,我需要再次调用该 API,我尝试了 if else 和 waitFor 方法但无法提出解决方案,我使用页面对象和测试规范,我无法将其创建为一种方法,因为在一页和一个 def 类中发生,我什至不能在我的测试类中执行 waitFor 导致 IllegalMonitorStateException
when: "I enter text code"
String text = response.getText()
testPage.enterCode << text
testpage.pager.clickNext() // here is happening the code expiration and couldn't get to the next page,
then: "I am in next page"
at nextPage // if am not on the next page I need to make a new api call to get the newest response
我试过了
when: "I enter text code"
String text = response.getText()
testPage.enterCode << text
testpage.pager.clickNext()
def erroHappened = testPage.errorAlert.isdisplayed
then: "I am in next page"
!errorHappened && testPage.enterCode << response.getText()
我如何使用等待或尝试捕获或其他方法来解决此问题,提前谢谢
解决方案
推荐阅读
- c++ - 为什么不能“推导出”明确给出的模板参数
- sql - 使用异步库编写同步代码的最佳方法是什么
- c - 为什么我在 C99 错误中得到函数“cambiar_color”的隐式声明无效
- python - 为什么 re.search('\.', '.') 不返回 None?
- aws-lambda - 如何授权 lambda 使用 CDK 执行 ses:SendEmail?
- node.js - 带有动态参数的 NestJS 注释
- openshift - 如何将openshift容器平台企业安装为一体式安装
- python - 将曲线样条拟合到 3D 点云
- sql - 使用 SQL 打印来自两个不同表的数据,但使用第三个表作为两者之间的链接
- java - 我试图在 RecyclerView 中接收一个包含数组的列表并得到错误: