Results 1 to 4 of 4

Thread: Vb.net document.getelementbyid() not working with chromium

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2019
    Posts
    37

    Vb.net document.getelementbyid() not working with chromium

    The new code I tried didn't seem to work so I'm looking for guidance on how my VB code setup for an IE browser can be converted to work in Chromium:

    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Value.Text = Value.Text - 1
    
        If Value.Text = 0 And
            WebBrowser1.DocumentText.Contains(User.Text) Then
    
            WebBrowser1.Document.GetElementById("msg").InnerText = R1.Text
           WebBrowser1.Document.GetElementById("submit").InvokeMember("Click")
            Value.Text = 240
            LatestActivity.Text = (DateTime.Now.ToString())
    
        End If
    End Sub
    The new code I've started with is simply:

    Code:
    browser.ExecuteScriptAsync("document.GetElementById('message').InnerText;" = R1.Text)
    But I unfortunately had no luck with it so any guidance is greatly appreciated.
    Last edited by nitrozity; Sep 10th, 2022 at 07:10 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Vb.net document.getelementbyid() not working with chromium

    This code:
    vb.net Code:
    1. browser.ExecuteScriptAsync("document.GetElementById('message').InnerText;" = R1.Text)
    is equivalent to this:
    vb.net Code:
    1. Dim flag As Boolean = ("document.GetElementById('message').InnerText;" = R1.Text)
    2.  
    3. browser.ExecuteScriptAsync(flag)
    That's clearly not what you want. I'm guessing that you actually want to execute that script and get the text result, then compare that to R1.Text, so do that. Also, if you're calling ExecuteScriptAsync then that's going to return a Task, so you probably need to await it or get the Result. You ought to look at existing examples of that method and see how they do it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2019
    Posts
    37

    Re: Vb.net document.getelementbyid() not working with chromium

    Thanks for your answer. I had the original code working fine with the built-in IE browser, but that only lasted so long since it's quite outdated by now. Is there a simpler way I can just translate my original code to work with Chromium?

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2019
    Posts
    37

    Re: Vb.net document.getelementbyid() not working with chromium

    Bump, still looking for assistance. TIA.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width