[英]c# selenium | how to get values in table same column
I wrote a code to list the names of the wordpress categories.我写了一个代码来列出 wordpress 类别的名称。 But I was not successful.
但我没有成功。 The category names column is marked in red.
类别名称列标记为红色。
https://i.stack.imgur.com/NnLk1.jpg 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: output:
https://i.stack.imgur.com/zzWgb.jpg 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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.