We would like to automate certain tasks on the website, for example, “log in” the user, perform some functions, read the history of their accounts, etc.
We tried to simulate this with the usual POST / GET, but the problem is that, for example, to “log in”, the site uses javascript code to make an AJAX call, and also generates some random tokens.
Is it possible to literally emulate a web browser? For instance:
- Visit www. [test-website] .com '
- Fill these DOM elements
- DOM username "username" is populated with "testuser"
- DOM password "password" is filled with "testpass"
- Click on the DOM button item 'btnSubmit'
- View account history
- Read HTML (so that we can analyze information about each individual element of the story)
- ...
The above can be translated as follows:
var browser = new Browser(); var pageHomepage = browser.Load("www.test-domain.com"); pageHomepage.DOM.GetField("username").SetValue("testUser"); pageHomepage.DOM.GetField("password").SetValue("testPass"); pageHomepage.DOM.GetField("btnSubmit").Click(); var pageAccountHistory = browser.Load("www.test-domain.com/account-history/"); var html = pageAccountHistory.GetHtml(); var historyItems = parseHistoryItems(html);
source share