The Html code of my click page is :
<input type="submit" id="publishButton-ns" class="ubtn ubtn-block"
name="publish" tabindex="10" value="Publish Post">
I tried this code for clicking:
webBrowser1.Document.GetElementById("publishButton-ns").InvokeMember("click");
but this not found the button.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
This may help you.
<input type="submit" value="Submit" />
HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement el in elc)
{
if (el.GetAttribute("type").Equals("submit"))
{
el.InvokeMember("Click");
}
}
Are you waiting for the page to load first? You should bind a function in your code to wait for the page to load, them click the button:
static void form1_Load() {
// ...
webBrowser1.onDocumentReady += webBrowser_DocumentReady;
}
static void webBrowser1_DocumentReady() {
webBrowser1.Document.GetElementById("publishButton-ns").InvokeMember("Click");
}
Try a combination of @adam's suggestion and capitalize Click
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document
.GetElementById("ctl00_main_LoginExpoPlanIt_LoginButton")
.InvokeMember("Click");
}
Just tested this and it didn't work with "click" but did with "Click" :)
I'm using .net 4
EDIT: This only applies when runat="server"
is set, not applicable in this case but leaving for others just in case, my apologies on missing that in the question.
ASP.Net changes the name of elements it renders based on the structure they are in, you can try the following to get the final name of the element:
webBrowser1.Document.GetElementById("<%=publishButton-ns.ClientID%>").InvokeMember("click");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With