À§¿Í °°ÀÌ id °¡ ÁÖ¾îÁöÁö ¾Ê¾ÒÀ» °æ¿ì¿¡´Â ¾î¶»°Ô ÇØ´ç À¥ ¹öÆ°ÀÌ Å¬¸¯µÈ °Í ó·³ ÇÒ ¼ö Àִ°¡°¡ Áú¹®ÀÇ ¿äÁö´Ù.
id ´ë½Å class ³×ÀÓÀ» ÀÌ¿ëÇÏ´Â Äڵ带 ÀϹÝÈ Çؼ ÇÔ¼ö¸¦ ¸¸µé¸é ´ÙÀ½°ú °°ÀÌ ¸¸µé ¼ö ÀÖ´Ù.
uses MsHtml;
procedure invokeClickByClass(Doc: IDispatch; className: string); var I: Integer; begin with ((Doc as IHTMLDocument2).body as IHTMLElement2).getElementsByTagName('*') do for I := 0 to Pred(length) do with item(I, EmptyParam) as IHTMLElement do if AnsiSameText(_className, className) then begin click(); Break; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin invokeClickByClass(WebBrowser1.Document, 'btn-sprite type-00 vmiddle search-btn'); end;
procedure invokeClickByClassName(Doc: IDispatch; csName: string); begin ((Doc as IHTMLDocument7).getElementsByClassName(csName).item(0, EmptyParam) as IHTMLElement).click(); end;
procedure TForm1.Button1Click(Sender: TObject); begin invokeClickByClassName(WebBrowser1.Document, 'btn-sprite type-00 vmiddle search-btn'); end;