0

I am dealing with a weird situation when I could not fill the facebook post area with text by using:

GeckoWebBrowser1.Document.GetElementsById("xc_message").SetAttribute("value", "hello world")

Meanwhile this works fine with VB.NET default Webbrowser and the below code works fine for facebook Login:

GeckoWebBrowser1.Document.GetElementById("email").SetAttribute("value", TextBox1.Text)
GeckoWebBrowser1.Document.GetElementById("pass").SetAttribute("value", TextBox2.Text)
GeckoWebBrowser1.Navigate("javascript:void(document.forms[0].submit())")

I thought it should be similar however an error occurs when compiling:

Compiling error image

This is how it looks like, however I can not set a status message still.

Element inspection Image

Dharman
  • 30,962
  • 25
  • 85
  • 135
Anh Ba
  • 11
  • 3
  • `GetElementsById("xc_message")` returns an object for default browser, but not Gecko, is that correct? If it doesnt return the object you can't set the attribute and hence the null reference exception. – Trevor May 29 '18 at 04:03
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Trevor May 29 '18 at 04:04
  • _“Could you advise me?”_ - Yes: Any such attempts to automate login are against Facebook’s ToS, and if you get caught, you might end up getting your account blocked. – CBroe May 29 '18 at 06:36
  • @CBroe Actually, it is not illegal. It is browser-based login method - the basic ^^. – Anh Ba May 29 '18 at 07:28
  • @Codexer I tried with Webkit.Net also. The Id named "xc_message" does apply for Webkit (which is chrome browser based). And that id also exists for default VB.Net browser (which is IE based). So I think it is no problem with Gecko...But no work : (. The NullReferenceException you linked says a lot about everything so It is hard to solve the problem that way. Also, it runs well with the login part (no exception thrown) so I don't really understand...hmm – Anh Ba May 29 '18 at 07:30
  • @AnhBa He didn't say it was illegal. He said it was against Facebook Terms of Service and most likely your account will be banned if you do it – WizKid May 29 '18 at 16:34
  • @WizKid I actually run a facebook poster used VB.NET webbrowsers for months and my account is still working. It is the basic things like you open a webbrowser and enter login information...:D – Anh Ba May 31 '18 at 04:48
  • Updated! Not yet answered. – Anh Ba Jun 14 '18 at 08:44

1 Answers1

0

After a while sorting out by googling. This is what works out:

Dim MyFBstatus As New GeckoTextAreaElement(GeckoWebBrowser1.Document.GetElementsByTagName("TEXTAREA")(0).DomObject) MyFBstatus.Value = "TESTING"
Dharman
  • 30,962
  • 25
  • 85
  • 135
Anh Ba
  • 11
  • 3