cefsharp how to check of all java script in page are completed?

柔情痞子 提交于 2019-12-24 11:28:30

问题


Iam using CefSharp browser and c# .

i try login to page but when i click the submit button the page didnt refresh untill login sucess and if not the page load in server and get message password error

How i can Check if all java script in page after i submit ?

//Initialize ChromiumWebBrowser
Chromium = new ChromiumWebBrowser("www.exapmle.com/login");

        this.panel2.Controls.Add(chrom);
        Chromium.Show();
        Chromium.Dock = DockStyle.Fill;

click submit button var cvbar = chrom.EvaluateScriptAsync("document.getElementById(\"login_u\");

I want Here To check if all javascript completed something like this

 if(javascripteCompleted()
 {
        var response = cvbar.Result;
        if (response.Success == true && response.Result.ToString() != "")
        {
          //  MessageBox.Show(response.Result.ToString());
        }
  }

thanks


回答1:


this is what i did to show webpage only when its loaded and until then show SPINNER

private void Cefbrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
    {
        if (!e.IsLoading)
        {
            Application.Current.Dispatcher.Invoke(delegate
            {
                myspin.Visibility = Visibility.Collapsed;
            });

        }
    }

my XAML code

<StackPanel Name="panel">
            <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MinHeight="700" Height="{Binding ElementName=panel,Path=ActualHeight}" Name="maingrid">
                <fa:ImageAwesome Name="myspin" Icon="Spinner" Spin="True" SpinDuration="4" Height="80" />
            </Grid>
        </StackPanel>

initally i put a fontawesome spinner which shows that the page is loading when the loading state changes if (!e.IsLoading) is fullfilled, then the spinner goes into the background and webWINDOW is loaded like this: -

chrome.Load(URL);

**FYI Loading_State_Changed works when entire page html + javascript + css loads **



来源:https://stackoverflow.com/questions/53160587/cefsharp-how-to-check-of-all-java-script-in-page-are-completed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!