在网站上有相同的ID [英] on the website there is same id

查看:67
本文介绍了在网站上有相同的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网站上有相同的id文本框,但是当我写作时 

        WebBrowser1.Document.All(" username")。SetAttribute(" value",username)

其写入不同的文本框,具有相同的ID" username"



< input name =" username" ID = QUOT;用户名"类型= QUOT;文本"类= QUOT;使用者" autocomplete =" off"

placeholder =" Kullanici Adi"> b $ b $
i需要达到第二场但我无法达到 

< input type =" text" ID = QUOT;用户名" class =" input4"

  autocomplete =" off"命名= QUOT;用户名"值= QUOT;" required ="" 

data-required ="" data-pattern =" ^ [a-zA-Z] [a-zA-Z0-9] + $" 

data-minlenght =" 6" data-maxlenght =" 12"

  onkeyup =" clearNonAlphaNum(this)">


请帮助我

解决方案

https://developer.mozilla.org/en-US/docs/Web/API/Element


你应该能够解决Elelment.Id和Eleliment.Classname。


你看到它在循环中完成了。


https://stackoverflow.com/questions/16181773/loop-over-every-htmlelement-on-a-page-in-a-webbrowser-control


由于元素集合正在重新调整,您可以使用Linq查询元素并重新调整对象。


  dim elm =(来自 webBrowser1 文件 全部


          其中a.Id =" username"和a.Classname =" input4" select a) SingleOrDefault()


如果不是IsNoth ing(elm)然后


  dim id = elm.ID


  dim classname = elm.classname


end if if


尝试使用Linq语句或进入循环以查找所需的元素。


on the website there is same id textbox but when i am writing 
        WebBrowser1.Document.All("username").SetAttribute("value", username)
its writen different textbox with same id "username"

<input name="username" id="username" type="text" class="user" autocomplete="off"
placeholder="Kullanici Adi">

i need to reach second field but i couldnt reach 
<input type="text" id="username" class="input4"
 autocomplete="off" name="username" value="" required="" 
data-required="" data-pattern="^[a-zA-Z][a-zA-Z0-9]+$" 
data-minlenght="6" data-maxlenght="12"
 onkeyup="clearNonAlphaNum(this)">

please help me

解决方案

https://developer.mozilla.org/en-US/docs/Web/API/Element

You should be able to address the Elelment.Id and Eleliment.Classname.

You see it being done in the loop.

https://stackoverflow.com/questions/16181773/loop-over-every-htmlelement-on-a-page-in-a-webbrowser-control

Since a collection of elements are being retuned, you can use Linq to query the elements and get an object retuned.

 dim elm = (From a in webBrowser1.Document.All

                   Where a.Id = "username" and a.Classname = "input4" select a)SingleOrDefault()

If not IsNothing(elm) then

  dim id = elm.ID

  dim classname = elm.classname

end if

Either try the Linq statement or go into a loop to find the element wanted.


这篇关于在网站上有相同的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆