Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't my code find the login form field from mail.com?

A previous question showed that fld in the following code is nil.

procedure TForm1.Button2Click(Sender: TObject);
var
  doc: IHTMLDocument2;
  frm: IHTMLFormElement;
  fld: IHTMLInputTextElement;
begin
  doc := webbrowser1.Document as IHTMLDocument2;
  frm := doc.forms.item(0, EmptyParam) as IHTMLFormElement;
  fld := frm.item('login', EmptyParam) as IHTMLInputTextElement;

I have a TWebBrowser that goes to mail.com and I am wondering why frm.item returns nil. It leads me not being able to fill in the field. On a different website, for example gmail.com, it does work when I fill in instead of 'login' - 'email'.

I am pretty sure the name of the field is 'login' because I can find this from the page's HTML: <input type="text" name="login" id="login" class="text" ...>.

like image 801
dave123 Avatar asked Dec 09 '25 12:12

dave123


1 Answers

I believe the answer to my own oh so stupid question is pretty straight forward. If you replace the 0 with a 2. It does work, because there are multiple forms on the page and the specific field 'login' is in form 2 of the html page

like image 65
dave123 Avatar answered Dec 11 '25 01:12

dave123



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!