简体   繁体   中英

c# selenium | how to get values ​in table same column

I wrote a code to list the names of the wordpress categories. But I was not successful. The category names column is marked in red.

https://i.stack.imgur.com/NnLk1.jpg

this is the code I wrote:

var table = driver.FindElement(By.TagName("tbody"));
var rows = table.FindElements(By.TagName("tr"));
foreach (var row in rows)
{
    IList<IWebElement> satirlar = row.FindElements(By.TagName("td"));
    foreach (var satir in satirlar)
    {
        var a = satir.Text;
        listBox1.Items.Add(a);

    }
}

output:

https://i.stack.imgur.com/zzWgb.jpg

I just want to list the category names. but the number of articles in the category and the short name of the category are listed. I don't want this to happen. Only category names should be listed. Can you help me please?

Try this:

var a=satir.FindElement(By.CssSelector("a.row-title")).Text;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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