简体   繁体   中英

c# - How to launch a website in a browser and insert javascript in that browser?

How can I launch a website in c#, and insert javascript in it?

Basically what I am doing is, I created a windows forms application with textfields that match the textfields in a website, and after filling in the fields in the forms application, it needs to open that site in a browser (with a query string that has the values in the textfields), and then insert some javascript in the DOM which will then add those values in the textfields and then invoke the click command of the submit button.

Thanks.

Omega,

You are looking for Web Browser Automation, see below:
Website Testing - Automation, Autofill, etc. (C# WinForms)
Microsoft Web Browser Automation using C#

Also see if this library helps you:
http://seleniumhq.org [never used it personally tho]

But I don't know why you want to inject JavaScript... if that is to set values of textboxes and button click, you can do it via code behind in C#... You have the Document object of AxWebBrowser or WebBrowser control in Windows Forms and you can play with it!

I hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM