简体   繁体   English

如何为 Select 名称 class 编写 xpath 以用于 Z9E13B69D1D2DA927102ACAAAF7Z14 中的以下场景?

[英]How to write xpath for Select name class for the below scenario in Javascript?

在此处输入图像描述

Hello,你好,

I'm trying to choose a card from the card list(as shown in the below screenshot) and the locator for the same is highlighted in the "Elements" section.我正在尝试从卡片列表中选择一张卡片(如下面的屏幕截图所示),并且相同的定位器在“元素”部分中突出显示。 This is a Select name class and the below xpath didn't work for me.这是一个 Select 名称 class 和下面的 xpath 对我不起作用。 Could you please help me if there is other way to write the xpath?如果还有其他方法可以编写 xpath,您能帮我吗?

//select[@class='co-dropdown__select co-payment-card__select']//option[2] //select[@class='co-dropdown__select co-payment-card__select']//选项[2]

try using this:尝试使用这个:

WebElement dropDownList = driver.findElement(By.cssSelector(".co-dropdown__select.co-payment-card__select")); 
Select card= new Select(dropDownList);
card.selectByIndex(2);

Try below css selector试试下面的 css 选择器

 Select select= new Select(driver.findElement(By.cssSelector("select.co-dropdown_select.co-payment-card__select")));    
 select.selectByIndex(index);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM