I have a TWebBrowser
component in the form that loads a page html
(a Form
), automatically populates the data and sends it through the
WebBrowser1.OleObject.Document.all.Item('enviar', 0).Click;
After the response page loads, the program analyzes the information on the page (which is the second part of the form) and I make the same command to send that second form.
When I isolate the events in two buttons
, everything works correctly, but joining the commands in the same sequence gives a fatal error.
I have tried to use a Sleep(4000)
after the 1st sequence to give time to load the page of the second Form , but it still gives error.
Any suggestions?
Code snippet:
WebBrowser1.OleObject.Document.all.Item('login', 0).value := 'usuario';
WebBrowser1.OleObject.Document.all.Item('senha', 0).value := 'senha';
WebBrowser1.OleObject.Document.all.Item('enviar', 0).Click;
Sleep(4000);
.... Processamento dos dados ....
WebBrowser1.OleObject.Document.all.Item('enviar2', 0).Click;