如何通过单击 table 中的单选按钮随机 select 动态值 - 无法单击单选按钮
How to Randomly select the dynamic value by clicking on the Radio button in a table -Not able to click on the Radio button
我有一个 table,我需要每次单击单选按钮 select 动态值。
我尝试过的:
我先取了table单选按钮列表:
List<WebElement> radiobuttonoptions = driver.findElements(By.xpath("(//table[contains(@class,'mat-table cdk-table')])
[2]//following::span[contains(@class,'mat-radio-outer-circle')]"));
然后我获取专栏列表 - 我已按需要完成此操作
select OPTION 栏中以OPT开头的任意选项
这是列表:
List<WebElement> section = driver.findElements(By.xpath("//tbody[@role='rowgroup']/tr/td[2]"));
现在如果已经从部分列表中获取文本并检查列
有文本 :opt
for(WebElement optinselection:optselection)
{
{
Then i randomly go and click on the radio button
{
Random random = new Random();
int index = random.nextInt(radiobuttonoptions.size());
radiobuttonoptions.get(index).click();
}
**我的问题是没有点击单选按钮。
任何输入都将是 helpful.Any 需要更多信息我可以添加。**
有人可以提供意见吗?
正如所讨论的,xpath //input[contains(@id,'mat-radio')]
可以点击单选按钮。如果 input
标签在 span
内,那么过程应该有点像这样。
radiobuttonoptions = driver.findElements("xpath for `span` that contains `VESE`")
Random random = new Random();
int index = random.nextInt(radiobuttonoptions.size());
radiobuttonoptions[index].#find element by tag name `input` .click();
我有一个 table,我需要每次单击单选按钮 select 动态值。
我尝试过的:
我先取了table单选按钮列表:
List<WebElement> radiobuttonoptions = driver.findElements(By.xpath("(//table[contains(@class,'mat-table cdk-table')])
[2]//following::span[contains(@class,'mat-radio-outer-circle')]"));
然后我获取专栏列表 - 我已按需要完成此操作
select OPTION 栏中以OPT开头的任意选项
这是列表:
List<WebElement> section = driver.findElements(By.xpath("//tbody[@role='rowgroup']/tr/td[2]"));
现在如果已经从部分列表中获取文本并检查列
有文本 :opt
for(WebElement optinselection:optselection)
{
{
Then i randomly go and click on the radio button
{
Random random = new Random();
int index = random.nextInt(radiobuttonoptions.size());
radiobuttonoptions.get(index).click();
}
**我的问题是没有点击单选按钮。
任何输入都将是 helpful.Any 需要更多信息我可以添加。**
有人可以提供意见吗?
正如所讨论的,xpath //input[contains(@id,'mat-radio')]
可以点击单选按钮。如果 input
标签在 span
内,那么过程应该有点像这样。
radiobuttonoptions = driver.findElements("xpath for `span` that contains `VESE`")
Random random = new Random();
int index = random.nextInt(radiobuttonoptions.size());
radiobuttonoptions[index].#find element by tag name `input` .click();