Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Automating Tasks in a Browser

Hey, I'm hoping to make bots that automate tasks in a browser. I have a quite a bit of programming experience in PHP, however that wouldn't work for this type of task. I can understand the fundamentals of C#, but what should I look into if I want to create this type of thing.

Thanks,

mrphp
You can invoke a web browser control but it would be better to do web requests.
Look into the robot framework, can't get any simpler, or search for "Selenium webdriver". Not sure if there's a C# port, but there are other tools out there. You can also play around with Jasmine/Mocha if you know javascript.

I always start people off with the robotframework.
(Aug 11, 2017 01:53 PM)VouchPotato™ Wrote:  Look into the robot framework, can't get any simpler, or search for "Selenium webdriver". Not sure if there's a C# port, but there are other tools out there. You can also play around with Jasmine/Mocha if you know javascript.

I always start people off with the robotframework.

I googled robotframework and found something related to testing.
Depending on exactly what you want to achieve (or how "nice" do you want to do it), you have more options (i'll list only the ones i've used):

- Using the build in webbrowser and invoke actions on the elements
- Using webrequest, imitating the browser (Now i have made a Forge of Empires bot using this method)
- Use sockets for the communication (i do NOT recommend this, it's pointlessly complicated, just listed it, bc i've tried it before)

So maybe if you tell us, what you want to do, we may be able to help better.

PS.: Oh, i almost forgot, you can imitate simple user clicks and keypresses, but thats really a pain in the ass, if the form changes etc,etc... (Also, you cant do other things, bc if i know well, you can send inputs only to the active window, if this is not true, i would be happy to learn a way to do it :) )
@hackpet and all others I'm hoping to do this with web requests. Is there anything else to know if I am planning on doing it that way?
(Aug 11, 2017 05:04 PM)mrphp Wrote:  @hackpet and all others I'm hoping to do this with web requests. Is there anything else to know if I am planning on doing it that way?

One more tip, which may be useful. I used Fiddler to log all the communication between me and the webserver, this way i could "copy" the syntax of that.

If you need any help just feel free to ask ;)
(Aug 11, 2017 05:04 PM)mrphp Wrote:  @hackpet and all others I'm hoping to do this with web requests. Is there anything else to know if I am planning on doing it that way?

Get a packet sniffer like Fiddler or Charles so you can sniff the HTTP requests, then emulate them using WebRequests (or WebClient (or HttpClient)). If you want to use WebRequests, I made some extension methods:
https://hackforums.net/showthread.php?tid=5530456

For WebRequests (or WebClient (or HttpClient)) you have to do session handling yourself, unlike the WebBrowser. You do this using a CookieContainer.
Selenium is a very, very easy way of controlling a browser programmatically.
(Feb 3, 2018 03:19 PM)kickball34 Wrote:  i'm gonna get your ip address and rat your pc.
(Aug 11, 2017 03:00 PM)Ninja Wrote:  I googled robotframework and found something related to testing.

That's what it was made for, but you can automate whatever you want, doesn't need to be a test automation.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by dinosaur770Jul 9, 2022 10:57 PM 6 129 Jul 9, 2022 10:57 PM
Last Post: dinosaur770
[Python] by DarkMay 17, 2019 08:08 PM 1 207 May 17, 2019 08:08 PM
Last Post: demarco
[Python] by DisparityFeb 18, 2018 01:35 PM 2 119 Feb 18, 2018 01:35 PM
Last Post: Disparity