Witam.
Chciałbym napisać swój kreator kont pocztowych, coś takiego jak ten wbudowany w MailShare, Moorhunta czy Ygoowa. Na początek wybrałem zakładanie kont na wp.pl. Napisałem kod w C# (w Visual Studio 2013), który nie do końca działa - ładuje się strona w programie, klikam "Nowe konto" i wszystkie pola się wypełniają. Problem w tym, że dwa pola "Login" i "Hasło" też są wypełnione, a świecą na czerwono, reszta ok.
Lecz gdy np. skasuję jakiś znak (np. ostatni - "a" jak na screenie) i wpiszę go ponownie z klawiatury to zaczyna świecić na zielono. Z hasłem podobnie. Gdy na przykład dopiszę jakąś literę z klawiatury do obecnego hasła, to też działa. Zamieszczam poniżej fragment kodu, siedziałem nad tym kilka dobrych godzin, przeszukałem Google i nic... Fajnie, gdyby ktoś poradził / napisał co jest nie tak.
public Form1()
{
InitializeComponent();
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (e.Url.AbsolutePath != (sender as WebBrowser).Url.AbsolutePath)
return;
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("https://profil.wp.pl/rejestracja.html");
}
private void button1_Click(object sender, EventArgs e)
{
string url;
HtmlElementCollection theElementCollection;
theElementCollection = webBrowser1.Document.GetElementsByTagName("img");
foreach (HtmlElement curElement in theElementCollection)
{
if (curElement.GetAttribute("src").ToString().Contains("https://si.wp.pl/captcha?"))
{
url = curElement.GetAttribute("src").ToString();
pictureBox1.Load(url);
}
}
webBrowser1.Document.GetElementById("firstName").SetAttribute("value", imie);
webBrowser1.Document.GetElementById("lastName").SetAttribute("value", nazwisko);
webBrowser1.Document.GetElementById("plec-mężczyzna").InvokeMember("click");
webBrowser1.Document.GetElementById("birthDateDay").SetAttribute("value", dzien2);
webBrowser1.Document.GetElementById("birthDateMonth").SetAttribute("value", miesiac2);
webBrowser1.Document.GetElementById("birthDateYear").SetAttribute("value", rok2);
webBrowser1.Document.GetElementById("login").SetAttribute("value", imie + nazwisko);
webBrowser1.Document.GetElementById("darmowa").InvokeMember("click");
webBrowser1.Document.GetElementById("cloudAccount").InvokeMember("click");
webBrowser1.Document.GetElementById("password").SetAttribute("value", haslo);
webBrowser1.Document.GetElementById("passwordRepeat").SetAttribute("value", haslo);
webBrowser1.Document.GetElementById("helperEmail").SetAttribute("value", email + "@wp.pl");
webBrowser1.Document.GetElementById("citySize").SetAttribute("value", "1");
webBrowser1.Document.GetElementById("education").SetAttribute("value", "1");
webBrowser1.Document.GetElementById("job").SetAttribute("value", "1");
webBrowser1.Document.GetElementById("zgodaTerms").InvokeMember("click");
}
private void button2_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("captchaCode").SetAttribute("value", textBox1.Text);
webBrowser1.Document.GetElementById("btnSubmit").InvokeMember("click");
richTextBox1.AppendText("L: " + imie + nazwisko + "@wp.pl" + "\n");
richTextBox1.AppendText("P: " + haslo +"\n");
richTextBox1.AppendText("\n");
}