I have written some code to allow me to create an account automatically on a website using C#. Unfortunately the code does not seem to be working as intended as I'm not getting a confirmation e-mail from the site.
Here's my code (i only copied the important parts to make it as objective as possible)
webBrowser.Navigate("https://account.protonvpn.com/signup");
webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
MessageBox.Show("end");
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser.ReadyState != WebBrowserReadyState.Complete)
return;
if (webBrowser.Url.ToString() == "https://account.protonvpn.com/signup")
{
buttons = webBrowser.Document.GetElementsByTagName("button");
foreach (HtmlElement button in buttons)
{
if (button.InnerText == "Get Free")
{
button.InvokeMember("click");
MessageBox.Show("clicked");
}
else
{
MessageBox.Show("not clicked");
}
}
return;
}
if (webBrowser.Url.ToString() == "https://account.protonvpn.com/signup/account")
{
webBrowser.Document.GetElementById("username").SetAttribute("value", "username");
webBrowser.Document.GetElementById("password").SetAttribute("value", "password");
webBrowser.Document.GetElementById("passwordConfirmation").SetAttribute("value", "password");
webBrowser.Document.GetElementById("email").SetAttribute("value", "email");
buttons = webBrowser.Document.GetElementsByTagName("button");
foreach (HtmlElement button in buttons)
{
if (button.InnerText == "Create account")
{
button.InvokeMember("click");
MessageBox.Show("account created");
}
else
{
MessageBox.Show("error");
}
}
return;
}
if (webBrowser.Url.ToString() == "https://account.protonvpn.com/signup/verification")
{
buttons = webBrowser.Document.GetElementsByTagName("button");
foreach (HtmlElement button in buttons)
{
if (button.InnerText == "Send")
{
button.InvokeMember("click");
MessageBox.Show("account created!");
}
else
{
MessageBox.Show("error!");
}
}
return;
}
}
I am also encountering some "script errors" when running my code, not sure how to fix them and not sure if this affects anything when running the code.