WebDriverWait w = new WebDriverWait(driver, 10);
w.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Credit Card")));
链接“信用卡”是一个UI标签。
我无法点击链接。
我得到陈旧元素参考例外
HTML
<div class="paymnt_nav" ng-show="$parent.mobileInfo.isMobile==false || closePaymentMode != true">
<ul>
<li class="ng-hide"
ng-click="viewParams.webPaymentTabs='SC';resetCards('');removeBinOffer(true,true);checkOffer('storedCard',paymentMerchant.storeCardDTOList[0].cardToken,0,'',true);storeCardSelect();"
ng-show="viewParams.savedCards==true">
<li class="ng-scope"
ng-if="paymentMerchant.paymentOption.cc !='-1' && paymentMerchant.paymentOption.cc !=null">
<a class="''"
ng-class="{'active':viewParams.webPaymentTabs=='CC','':viewParams.webPaymentTabs!='CC'}"
ng-click="$parent.closePaymentMode = true;viewParams.webPaymentTabs='CC';paymentObject.paymentType='CC';resetCards('creditcard');removeBinOffer(true,true);handleSpecificConvenienceFee();_handlingCashBackScenario({})">
</li>
<li class="ng-scope"
ng-if="paymentMerchant.paymentOption.db !='-1' && paymentMerchant.paymentOption.db !=null">
<li class="ng-scope"
ng-click="$parent.closePaymentMode = true;viewParams.webPaymentTabs='NB';paymentObject.paymentType='NB';resetCards('netbanking');removeBinOffer(true,true);autoSelectNetBanking();_handlingCashBackScenario({});checkForNBStatus();"
ng-if="paymentMerchant.paymentOption.nb !='-1' && paymentMerchant.paymentOption.nb !=null">
<li class="ng-scope" ng-if="paymentMerchant.loyltyEnabled==true">
</ul>
</div>
答案 0 :(得分:0)
您应该在这些主要UI元素上放置ID以进行有目的的硒测试。在DOM中查找链接文本并不是一种好习惯,可能会导致测试不稳定。尝试添加ID并按ID查找元素。