如何在页面加载时向下滚动-geckofxc#

如何在页面加载时向下滚动-geckofxc#,c#,geckofx,C#,Geckofx,我想在Geckofx45中加载页面时向下滚动。 我试图使用以下代码,但似乎不起作用 wb.Navigate("javascript: var s = function() { window.scrollBy(550, 10000); }; s();"); 这怎么可能 int scrollTo = 30; public void scrollDown() { this.wb.Focus(); string result = string.E

我想在Geckofx45中加载页面时向下滚动。 我试图使用以下代码,但似乎不起作用

   wb.Navigate("javascript: var s = function() { window.scrollBy(550, 10000); }; s();");
这怎么可能

 int scrollTo = 30;
    public void scrollDown()
    {
        this.wb.Focus();
        string result = string.Empty;
        AutoJSContext context;
        string jsScript = string.Empty;
        try
        {
            if (scrollTo > 100)
            {
                scrollTo = 5;
            }

            context = new AutoJSContext(this.wb.Window);
            jsScript = "var x = document.getElementsByClassName('ANY_ELEMENTS_CLASS_NAME');   x[" + (scrollTo * 2) + "].scrollIntoView(); ";// CHANGE ANY_ELEMENTS_CLASS_NAME 

            context.EvaluateScript(jsScript, (nsISupports)wb.Window.DomWindow, out result);
            scrollTo += 5;
        }
        catch (Exception e)
        {
        }
    }

这对我很有帮助

或者,在不使用AutoJSContext的情况下,看看这个答案,这也很有帮助。。谢谢