【发布时间】:2019-04-26 03:27:49
【问题描述】:
我对赛普拉斯有疑问。
我在页面上有一个元素并不总是出现。什么时候显示什么时候不显示都没有逻辑。
在赛普拉斯中是否有一些 IF/THEN 函数或其他东西,您如何检查元素是否显示(所以填充它)以及当您看不到它时跳过该步骤?
我的代码:
if (Cypress.$('[data-bind="validationElement: interestInsurable"]').length > 0) {
cy.get('[for="p4-conditional-csob-interest-insurable-1"]').click()
}
else {cy.get('#car-info-serie')}
这是在操场上的样子: Picture
还有那个复选框的 HTML:
<label class="z-radio z-radio-inline primary" for="p4-conditional-csob-interest-insurable-1" data-bind="popover: { content: VehicleInsuranceTooltips.conditionalDataCsobInterestInsurable1Tooltip }" data-original-title="" title="">
<input id="p4-conditional-csob-interest-insurable-1" name="p4-conditional-csob-interest-insurable" type="radio" class="custom-radio" data-toggle="radio" data-bind="checkedValue: 1, checked: interestInsurable" value="1">
<span class="icons">
<span class="icon-unchecked"></span>
<span class="icon-checked"></span>
</span>
Patří vozidlo zájemci o pojištění?
</label>
【问题讨论】:
-
怎么可能没有关于它何时显示的逻辑?是什么让它显示出来?我想我对一个元素如何决定自己出现在你的 dom 中感到困惑。你能解释更多吗?
-
有产品可以选择。它们按价格排序,并且价格随着之前的每个字段而变化。只有两种产品具有该元素。
标签: if-statement testing automation cypress