0
<div id="lowbtn">
            <a href="javascript:;" class="start" a2s="click" obj="MAIN_START" opt="{&quot;Name&quot;:&quot;L_Start&quot;}"><img src="http://test/btn.png" alt="Go!" class="loading" data-was-processed="true"></a>
            <ul class="server" style="display: none;">
                <li class="Talk">
                    <span class="icon"><img src="http://test/assets/common/btn/icon.png" alt="" class="loading" data-was-processed="true"></span>
                    voice
                    <a href="javascript:;" class="on" id="a_voice_check"><span class="hide">on</span></a>
                </li>
            </ul>
        </div>

my delphi code

procedure TMainForm.WebBrowser1DocumentComplete(ASender: TObject;
  const pDisp: IDispatch; const URL: OleVariant);
var
  CurrentBrowser: IWebBrowser2;
  TopBrowser: IWebBrowser2;
  Document: OleVariant;
  Doc3 :  IHTMLDocument3;    
begin
  CurrentBrowser := pDisp as IWebBrowser2;
 TopBrowser := (ASender as TWebbrowser).DefaultInterface;
 if Assigned(CurrentBrowser) and Assigned(TopBrowser) then
  begin
   if CurrentBrowser = TopBrowser then
    begin

   doc3 := (pDisp as IWebBrowser2).Document as IHTMLDocument3;

   doc3.getElementById('lowbtn').click;     


  end;


  end;

I've tried different methods, but AV is occurring or doesn't work. Does anyone know a problem with my code or know a solution?

thx..

3
  • 1
    On which line is the AV occurring? Use the debugger to find out. Commented May 16, 2021 at 16:01
  • According to my experience, the DocumentComplete event is frequently triggered before the document and all dependencies have been downloaded. To verify this, put your code behing a TButton that you'll click when you see the document is really complete, or use a TTimer to defer the code for long time enough (just for testing, don't do that in production). Commented May 16, 2021 at 16:04
  • What strikes me sporadically: div-Element id="lowbtn" has no Click. Instructions can be found at: github.com/delphidabbler/articles/blob/master/… to github.com/delphidabbler/articles/blob/master/… Commented Jun 23, 2021 at 10:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.