[英]C# How to open a webpage and click a button
I have a problem to solve. 我有一个要解决的问题。
A button has this code: 一个按钮具有以下代码:
WebBrowser wb = new WebBrowser();
wb.Navigate(link, true);
wb.Document.GetElementById(idname).InvokeMember("click");
I have a NullReferenceException on the GetElementById because when I reach it, the page is "white". 我在GetElementById上有一个NullReferenceException,因为到达该页面时,页面为“白色”。 If I comment the GetElementById, the page is opened correctly. 如果我评论GetElementById,则页面将正确打开。
Thanks 谢谢
Here it is: 这里是:
private WebBrowser _wb = new WebBrowser();
public FormMain()
{
_wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
InitializeComponent();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.