簡體   English   中英

如何從兩個具有相同類值的表中選擇一個表?

[英]How to select one of the tables from two tables with the same class value?

在UI上,我看到兩個表,每個表具有相同的類值,如何從這些表中選擇一個表?

喜歡:

<table class="content-grid" width="100%" cellspacing="0" cellpadding="0" summary="License Requirements by Type">
<table class="content-grid" width="100%" cellspacing="0" cellpadding="0" summary="Users and Unassigned devices">

如果必須選擇“第一張表”,我該怎么做。 我可以使用xpath嗎?

WebElement table = driver.findElement(By.xpath("//table[@class='content-grid']"));

我想它應該分別是//table[@summary='License Requirements by Type']划分//table[@summary='License Requirements by Type']//table[@summary='Users and Unassigned devices']

您可以使用xpath,如下所示:

//table[@class='content-grid'][1]
//table[@class='content-grid'][2]

CSS選擇器將幫助您選擇以下內容。

WebElement table = driver.findElement(By.cssSelector("table[summary='License Requirements by Type']"))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM