Simox
Simox

Reputation: 13

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

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

Upvotes: 1

Views: 1796

Answers (1)

Yash Soni
Yash Soni

Reputation: 764

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 **

Upvotes: 2

Related Questions