get all elements by tag name and invoke them in loop (C# webbrowser)

0
foreach(HTMLElement he in webBrowser.getElementByTagName("img"))
{
    if(he.getAttribute("id").Contains("img"))
        he.InvokeMember("click");
    while(webBrowser.IsBusy)
        Application.DoEvents;
}

this is code section in which I have problem. in first iteration htmlelement is invoked and corresponding page is loaded successfully but on invoking of second element it gives the following error:

System.UnauthorizedAccessException: 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))'

(Each element in loop is link to other page)

c#
winforms
asked on Stack Overflow Sep 9, 2019 by Sakoon • edited Sep 12, 2019 by Wyck

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0