Answer the question
In order to leave comments, you need to log in
Doesn't loop?
int i;
for (i = 0; i <= 10; i++)
{
Random rand_date = new Random();
foreach (HtmlElement element1 in webBrowser.Document.All)
{
if (element1.GetAttribute("name") == "migrationRequest.dayOfBirth")
{
element1.Children[rand_date.Next(1, element1.Children.Count)].SetAttribute("selected", "true");
}
}
foreach (HtmlElement element2 in webBrowser.Document.All)
{
if (element2.GetAttribute("name") == "migrationRequest.monthOfBirth")
{
element2.Children[rand_date.Next(1, element2.Children.Count)].SetAttribute("selected", "true");
}
}
foreach (HtmlElement element3 in webBrowser.Document.All)
{
if (element3.GetAttribute("name") == "migrationRequest.yearOfBirth")
{
element3.Children[rand_date.Next(1, element3.Children.Count)].SetAttribute("selected", "true");
}
}
Answer the question
In order to leave comments, you need to log in
looked at the site, looked at your questions, but isn't it better to use JS for such purposes?
Actually something like this, I checked it, it works all 11 times: D
public System.Windows.Forms.WebBrowser webBrowser = new System.Windows.Forms.WebBrowser();
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
for (i = 0; i <= 10; i++)
{
webBrowser.Navigate(new Uri("https://account.mojang.com/migrate"));
webBrowser.Navigated+=DoWork;
}
}
private void DoWork(object sender, WebBrowserNavigatedEventArgs e)
{
Random rand_date = new Random();
foreach (HtmlElement element1 in webBrowser.Document.All)
{
if (element1.GetAttribute("name") == "migrationRequest.dayOfBirth")
{
element1.Children[rand_date.Next(1, element1.Children.Count)].SetAttribute("selected", "true");
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question