c#剧作家-获取div中/dt和/dd元素的值



我有以下结构:

<dl class="er-ctrbs-review-totals-list" </dl>
<div data-qa="total-1">
<dt>Employee Name</dt>
<dd>Sam</dd>
</div>
<div data-qa="total-2">
<dt>Employer Name</dt>
<dd>ZenS</dd>
</div>
</dl>

我试图得到dt和dl的值。我尝试了:页面。具有[data-qa]属性的定位器,但它返回的定位器不是value。

Then I have try:

_page.Locator("xpath=//div[@data-qa='total-1']/dt");
_page.Locator("xpath=//div[@data-qa='total-2']/dt");

_page.Locator("xpath=*//div[@data-qa='total-1']/dt");
_page.Locator("xpath=*//div[@data-qa='total-2']/dt");

谁能帮助我,我怎么能得到标签和值下的div?I am trying to get the: Employee Name, Sam, Employer Name, ZenS

可以使用regeX,取<dt>和<dd>

var input = File.ReadAllText("data.txt");
string patternDD = "<dd.*?>(.*?)<\/dd>";
string patternDT = "<dt.*?>(.*?)<\/dt>";
var matchesDD = Regex.Matches(input, patternDD);
foreach (Match m in matchesDD)
Console.WriteLine(m.Value.Replace("<dd>", "").Replace("</dd>", ""));
//Sam - ZenS
var matchesDT = Regex.Matches(input, patternDT);
foreach (Match m in matchesDT)
Console.WriteLine(m.Value.Replace("<dt>", "").Replace("</dt>", ""));
//Employee Name - Employer Name 

相关内容

  • 没有找到相关文章

最新更新