我正在尝试在赛普拉斯中设置电话号码的国家/地区代码。如果我有一个“ id”可以使用,我会使用类似的
cy.get('#countryCode').select('+44')
但是我正在使用的代码没有可使用的ID。下拉HTML看起来像
<select _ngcontent-kln-c8="" aria-label="Country Code for home phone number" class="uppercase mat-input-element mat-form-field-autofill-control cdk-text-field-autofill-monitored ng-pristine ng-valid ng-touched" matnativecontrol="" id="mat-input-6" aria-describedby="mat-hint-3" aria-invalid="false" aria-required="false"><option _ngcontent-kln-c8="" style="display: none" value="">+null</option><!----><option _ngcontent-kln-c8="" class="uppercase ng-star-inserted" value="1: 44"> +44 (United Kingdom) </option><option _ngcontent-kln-c8="" class="uppercase ng-star-inserted" value="2: 353"> +353 (Ireland) </option>
任何帮助将不胜感激。谢谢
答案 0 :(得分:0)
完全没有问题。根据您提供的HTML代码段,我建议您使用aria-label
,因为它在页面上应该是唯一的。
cy.get('[aria-label="Country Code for home phone number"]').select(''+44')
如果您还有其他问题,请告诉我!