【问题标题】:How does puppeter sharp get the value of an attribute?puppeter sharp如何获取一个属性的值?
【发布时间】:2021-03-12 16:55:14
【问题描述】:

puppeter sharp如何获取属性的值?看来获取属性和控件不如Windows Forms WebBrowser方便。 在下面的代码中,获取不到type的值

var node=await  page.QuerySelectorAsync("#uid" );
var vv=await node.GetPropertyAsync("type");

html

<input name="uid" type="text" style="height:50px;font-size:20px;" onkeypress="txtEnter(this,event)" class="form-control" id="uid">

【问题讨论】:

  • C 编程语言在哪里?你需要有正确的标签
  • 看起来不太像 c 代码

标签: c# webautomation puppeteer-sharp


【解决方案1】:

我认为EvaluateFunctionAsync 是最直接的方法:

var type = await node.EvaluateFunctionAsync<string>("node => node.type");

【讨论】:

  • 我使用 document.getElementById("uid").getAttribute("type");
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-03-05
  • 2011-12-13
  • 1970-01-01
  • 1970-01-01
  • 2013-11-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多