WebScraping in Excel using Selenium – problem with readonly attributes

huangapple go评论59阅读模式
英文:

WebScraping in Excel using Selenium - problem with readonly attributes

问题

我想在一个网站中移除只读属性。我只能使用Excel VBA与Selenium来实现这个目的。

网页中的代码如下:

<input type="text" name="fchFin" id="fchFin" readonly="" value="2023-05-26" maxlength="10" size="10" onblur="validarFecha(this);">
英文:

I would like to remove the readonly attribute in a website. I can only use Excel VBA with Selenium in order to do this.

The code in the webpage is the following:

&lt;input type=&quot;text&quot; name=&quot;fchFin&quot; id=&quot;fchFin&quot; readonly=&quot;&quot; value=&quot;2023-05-26&quot; maxlength=&quot;10&quot; size=&quot;10&quot; onblur=&quot;validarFecha(this);&quot;&gt;

答案1

得分: 0

尝试这个

Dim iput As WebElement, rO As Boolean
Set iput = driver.FindElementByXPath("//*[@name='someName']")
driver.ExecuteScript "arguments[0].removeAttribute('readonly')", iput
rO = iput.Attribute("readonly")
英文:

try this

Dim iput As WebElement, rO As Boolean
Set iput = driver.FindElementByXPath(&quot;//*[@name=&#39;someName&#39;]&quot;)
driver.ExecuteScript &quot;arguments[0].removeAttribute(&#39;readonly&#39;)&quot;, iput 
rO = iput.Attribute(&quot;readonly&quot;)`

huangapple
  • 本文由 发表于 2023年5月30日 08:14:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76360935.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定