在c#dom中使用类名按一个按钮 [英] Press a button using class names in c# dom

查看:173
本文介绍了在c#dom中使用类名按一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我想按一个网站上的按钮,我不知道要使用什么代码。 HTML 行如下所示:

So basically I want to press a button in a website and i dont know what code to use. The HTML line looks like this:

<a href="#" class="Free" data-date="1498544574">Click Here</a>

我希望程序使用DOM点击该免费按钮。我试过这个:

I want the program to click on that Free Button using DOM. I tried this :

webBrowser1.Document.GetElementByClassName("free").InvokeMember("click");

但是由于某种原因,GetElementByClassName被突出显示(在visual studio 2015中)

But for some reason the GetElementByClassName is highlighted (in visual studio 2015)

我不能更改HTML,因为网站不是我的。

推荐答案

p>它突出显示,因为WebBrowser.Document中没有GetElementByClassName函数!

It's highlighted cause there is no function GetElementByClassName in WebBrowser.Document!

看看这个,也许这将有助于您:

Look at this, maybe it would help you:

如何选择GetElementByClass的一个类,并以编程方式点击它

这篇关于在c#dom中使用类名按一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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