How to Auto test the Javascript Webpage - c#

I tired to make a auto test program which can auto fill/click another webpage based application.
Want my software can eumerate the manually action, ex. click the items, fill the text box...
Now, I can load the page in C# WPF's webbrowser, but didn't know how to auto fill the javascript popup window. we cann't get the elements through funcs like GetElementId(); becasue the page seems written by javascripts.
I'm really a newer on C# and Web.Welcome everyone give comments. Many thanks!
This is the webpage I want to test:
This is the source html I got via IE->View->Source:

Related

How To Automate Text from a C# Textbox to a Div Textbox in a website

So I am simply making my life easier as a Youtuber content Creator by being able to post my own work onto Reddit Website. There is a time limit on how often I can Post here:https://www.reddit.com/submit. I am trying to automate the text box with text from a Textbox in C# every So often using a amount of times. I have tried several different Idea's since I'm using the Chromium WebBrowser under CefSharp. Here is a link to my full project so you can see for yourself: https://drive.google.com/drive/folders/1jR5xRGYGZuLG_rE5fCH4RbWEd2WeioFa?usp=sharing
I need help in the ability to Enter any text I have in my Textbox in Form 1, and when I Press Start, it opens the submit location (Plan on doing a auto sign in later) and then paste or "Automate" the typing of what I have in my Text Box onto the Text Box on the Website. How Can I do this? I need help!
Photo 1 of what my code in C# Works.
Photo 2 of what my code in C# Works.

Transferring an existing C# and ASP.NET Web Form site to Bootstrap

So I have an existing page that's running ASP.NET and C# in order to display a front-end for some PowerShell commands. This was all developed in the community/free version of Visual Studio 2017.
Pseudo-code is below
User browses to page in browser
Browser presents lists of buttons and text fields
User inputs options into fields and clicks a button
C# runs in backend to run a PowerShell command doing various things, dumping into a JSON file the results
C# returns the results to the page by reading the JSON and turning it into a C# object, displaying as a C# Table
What I have already is that page (and sub pages for different features), displaying results to a simple table or div and displaying the buttons and text fields using the default C# table and some custom HTML to display the JSON properly.
What I want though, is to be able to port those features and functions to a Boostrap template, so I can take advantage of the handy dropdown menus, fancy buttons, etc. that are provided by Boostrap. Specifically I'm looking at using Flatkit.
All of the examples I've seen have either been for MVC stuff, starts entirely from scratch, or uses very simplistic Hello World examples, neither of which help when tackling this task as my code is web form based and more complex than an About page.
So my question(s) is/are
a) How can I create ASP.NET controls that will both play nicely with Bootstrap and feed data back into the C# file for processing? Something that can duplicate an <asp:Button> essentially, without refreshing the page entirely.
b) How can I then create another control or similar element on the front-end side to display that information? I'm using a simple <asp:Table> currently
I have the backend PowerShell and most of the logic written, I just need to know how I can make it interact nicely with Bootstrap essentially.
Web dev is not my usual forte , so a lot of the tutorials feel like reading Ancient Greek as they assume I know JQuery, Angular, DOM, etc. So if there's knowledge I'm lacking to make this work, links would be great.
Thanks!
End of day, Bootstrap or any CSS framework applies styles to HTML elements. ASP.Net Web Forms Controls render "vanilla" HTML - though some can be unwieldy (like <form> input name and id attributes - re: ASP.net uses the same value).
They can be styled as needed. Look into CssClass
Hth.

Get user-highlighted text from a textbox in C# web

I have a web app in which I want to be able to highlight a word or two in a multi-line textbox, out of several paragraphs of text, and have a button click method manipulate the selected text.
I want to be able to store the selected text in a variable but I haven't been able to find a way to get highlighted text in System.Web.
I know that System.Windows textboxes have the SelectedText property which would be perfect, but unfortunately I don't know how to use anything but the asp.net framework with html pages and c# code behind.
Basically what I am after is an equivalent of TextBox.SelectedText that I can use in a web app, or an alternate route which will accomplish the same result.
The user will be writing the content into the textbox so suggested different controls need to be editable.
I have tried incorporating Javascript into my C# code but it proved too complicated for me, and I don't know how to create a solely javascript web app.
Thank you for your answers so far

How to screen-scrape 3 levels deep in C#

I have a url (http://www2.anac.gov.br/aeronaves/cons_rab.asp) where I need to post form data programatically. That is, programatically, I want to select the correct radio button and click the submit button. If you go to the url above, the radio button I need selected is "modelo." Clicking the "ok" button will bring back a form with 20k+ links on it.
I then want to traverse all 20k+ links and scrape the page that the links point to. Finally, I will take the information from the last page and put the data in an Excel spreadsheet.
What would be the best way to get to the third page to scrape the information? I've researched the HTML Agility Pack, HTTPWebRequest and the WebBrowser control, but I'm not sure which one to use.
UPDATE: On the first page, I must select a radio button and then simulate a button click that posts the form back to itself. The resulting page contains the 20K+ links I'm interested in; however, each link is a javascript function call. The JS function takes the link text, places it in a textbox and then clicks the submit button. How the hell do I automate that?
You should be able to do what you want with the HTML Agility pack:
http://htmlagilitypack.codeplex.com/
http://www.leeholmes.com/blog/2010/03/05/html-agility-pack-rocks-your-screen-scraping-world/
You should also consider iRobot:
http://irobotsoft.com/
ALSO:
1) What have you tried?
2) How far did you get? What problems/questions did you encounter?
Have you tried Selenium? It uses webdriver and I've done several screen scraping apps using it and have never had issues, even with realtime apps. You can use it with C# to drive a browser and grab what you need.

SharePoint 2007 Custom Webpart, saving data to the properties

How can I go about creating a custom Web Part that has a custom UI for editing. When the page is in Edit mode I have a special button show up "Edit" and when the user clicks on it it posts back to the page. I catch this and I want to display a custom UI so they can edit the web part properties. I need to be able to have rich text fields, and text fields that are editable and will post back so I can save them to the properties.
I'm struggling mostly with creating a RichTextField, or TextBox that I can grab the data in post back. I know how to do it if I outputted raw HTML to the page, then use HTTP.Context, but what's the C# way to do it?
Thanks!
You can check in your web part if page is in Edit mode or Display mode and render the controls accordingly.
How to tell if page is in edit mode on a non-publishing site
On postback, you can fetch the values and assign it to your web part properties. Since you are handing it custom, you will need to set dirty flag:
http://msdn.microsoft.com/en-us/library/ms157656.aspx
It sounds like you're putting a configuration UI into the web part itself?
The standard way to provide a configuration UI is via the toolpart - the tall thin window that appears down the right hand side of a page when you edit a web part.
These posts should give you a good introduction :-
How To: Custom Web Part Properties (ToolPart)
Creating a Web Part with a Custom Tool Part
(SharePoint 2003 but still relevant)

Categories