如何使用vb.net中的代码单击网站上的按钮 [英] How to click a button on a website with code in vb.net

查看:101
本文介绍了如何使用vb.net中的代码单击网站上的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

改进的问题:

实际上我正在开发一个vb.net桌面应用程序,其中我正在尝试添加浏览器并将导航到我公司的网站。

我希望应用程序自动点击一个星形的按钮。

因为我对html不是那么熟悉所以没有理解我通过查看页面源获得的网站代码。

但得到了按钮的代码,如下所示。

i明白html元素必须有一个id,但是没有给出的html元素的id按钮。

所以我无法点击带代码的按钮。



improved question:
actually i am developing a vb.net desktop application, in which i am trying to add a browser and will be navigated to my company's website.
on that i want the application to automatically click a button with a star shape.
as i am not so familiar with html so didnt understand the code of the website which i got by seeing the page source.
but got the code for the button which is shown below.
i understand that the html element must have an id, but there is no id for the html element given for this button.
so i am not able to click button with the code.

<button class="like-btn" type="submit">
<i class="icon-star"></i>
</button>

推荐答案





一旦浏览器窗口处于活动状态,请尝试使用以下代码发送Enter键。

Hi,

Once the brower windowe is active try sending Enter key stoke using the below code.
System.Windows.Forms.SendKeys.Send("{ENTER}");





谢谢



Thanks



如果有什么独特之处按钮,就像它只是这个按钮或它的标签类一样,你可以使用RegEx搜索你的来源,或者如果它重复而不是唯一的,如:



Hi if there is something unique about the button, like it class is just for this one button or its tag, you can search your source using RegEx or if its repeated and not unique like :

<button class="like-btn" type="submit">

</button>
<button class="like-btn" type="submit">

</button>
<button class="like-btn" type="submit">

</button>





和你想要的是冷杉,最后或其中一个,你可以使用 HtmlElement & HtmlElementCollection 并使用你的HtmlElementCollection变量索引来查找它。



查看 HtmlElement类 [ ^ ]了解更多信息。



抱歉我的英文。



and you want the firs, last or a unique one of them you can use HtmlElement & HtmlElementCollection and use index of your HtmlElementCollection variable to find it.

Check out HtmlElement Class[^] for more info.

sorry for my English.


这篇关于如何使用vb.net中的代码单击网站上的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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