1

I am trying to write an automation tool for a browser game that takes some data from the web page, in this case the data appears to be added using JS after the page has loaded, I assume this is where my issue is.

I'm trying to grab the text that the JS adds and save it to a variable, but when I try and find it using the WebBrowser component's DOM controls, it cannot find the text I need. The text IS there, you can see it on the browser window and the source should easily be found as I can see it when using Chrome's dev console/inspect element tool, when I target it using the DOM controls, VS makes it clear that it can't find it. I am 100% certain I was targeting it right and that I'm not pointing it in the wrong direction.

Is there a way for the WebBrowser to refresh/re-read the source without refreshing the page? Otherwise, how would you go about working around this?

Cheers, Tom.

0xVox
  • 116
  • 1
  • 1
  • 10
  • View Source and Chrome Dev tools do not look at the same thing. View Source is what is sent from the server. The dev conosle looks at the current DOM. So if JavaScript changed the page, it will be updated in the DOM source, but not in the View Source. You might want to look into Selenium if you are automating pages. – epascarello Jul 15 '13 at 13:37
  • I'd code the thing in JavaScript and run it as a browser plugin or greasemonkey script. Also this has already been answered. http://stackoverflow.com/a/9874628/884862 – Louis Ricci Jul 15 '13 at 13:42
  • Sorry for the repeated question I didnt see that. However would it work if I tried using JS scripts through the WebBrowser component? (I assume that's possible) – 0xVox Jul 15 '13 at 14:15

1 Answers1

0

One work around that springs to mind when puling text from something is to use MS Office document imaging. If the text always appears in a specific location on a page it should just be a question of taking a print screen of where the text appears and then running it thought to OCR. The advantage of this is it's pretty future proof, the game makes could change the method by which they display the text but as long as it's displayed you should be able to print screen it. :)

FraserOfSmeg
  • 1,128
  • 2
  • 23
  • 41