In C# WinForms, what's the proper way to get the backward/forward history stacks for the System.Windows.Forms.WebBrowser?
Check out http://www.bsalsa.com/downloads.html. This is a series of Delphi components (free source code, you can see an example of this here: http://staruml.cvs.sourceforge.net/staruml/staruml/staruml/components/plastic-components/src/embeddedwb.pas?revision=1.1&view=markup - it's the starUML projects code) and they have, among other things, a way to get at the history, favorites, etc using the IE MSHTML interfaces. It's written in Object Pascal but it shouldn't be too hard to figure out what's going on. If you download the "Embedded Web Browser Components Package" take a look at the stuff in EmbeddedWB_D2005\Source - there's all sorts of goodies there.
It doesn't look like it's possible.
My suggestion would be to catch the Navigated event and maintain your own list. A possible problem with that is when the user clicks back in the browser, you don't know to unwind the stack.
Related
Referring to this question here a past user was able to develop some C# code to perform SAP GUI Automation. However when looking online at tutorials/developer documentation for this library I was unable to find anything.
There are a lot of objects like like, GuiSession, GuiApplication, GuiConnection that I can't find information to online.
How would I go on to writing SAP GUI automation using C# without proper documentation?
There is very little documentation for SAP Scripting in general outside of the one resource posted in the linked question (http://www.synactive.com/download/sap%20gui%20scripting/sap%20gui%20scripting%20api.pdf).
However, I also found this resource (http://help.innowera.net/PR2008/2.00/SAP_Scripting_API.pdf) which is similar to the one above but I think has a bit more detail.
Further, there is a built-in help document within SAP that you can access from the "Customize Local Layout" Menu (click the Monitor Icon in the second-from-the-top toolbar or ALT+F12) and then selecting "SAP GUI Scripting Help"
All three of these resources are primarily for VB; however, the objects, methods and rules are nearly the exact same for C#.
That being said, I do not know of any API Documentation specific to C# at this time
How would I go on to writing SAP GUI automation using C# without proper documentation?
I suggest recording scripts in VB through SAP first so that you can at least get the IDs for each button, menu, and field you use for a particular report. Then you can copy the IDs from that script into your C#. Additionally, these VB scripts can help you determine which objects and methods to use in your C#.
You can access the script recording functionality through the same "Customize Local Layout" menu and selecting "Script Recording and Playback..."
This functionality records every mouse click and keyboard input inside of SAP in VB and stores the resulting script in %AppData%\SAP\SAP GUI\Scripts
As I find more resources for SAP Scripting with C#, I will post them here.
There's now this HTML documentation online:
SAP GUI Scripting API
GuiSession Object
GuiApplication Object
GuiConnection Object
Etc.
The documentation is in your Program Files > SAP. Then, search for this file "SAPGUIScripting.chm". This is the best documentation I've seen. It documents all class objects with their methods, properties and events. It will occasionally provide some direction on how to use some of the methods.
You can also click on the "SAP GUI Scripting Help" as seen below.
As far as using C#, you would use the methods and properties just like you would for any other C# object.
Best of luck and happy scripting!
I need to get information from couple of web sites . For example this site
What would be the best way to get all the links from the page so that the information could be extracted.
Some times need to click on a link to get other links inside that.
I tried Watin and I tried doing the same from within Excel 2007 with Web Data option.
Could you please suggest some better way which I am not aware of .
Ncrawler might be very useful for the deep level crawling . You could also set the MaxCrawlDepth for specifying the same.
Have a look at WGet. It is an incredibly powerful tool for mining the content of a single page or an entire website. The options available allow you to dictate how many levels deep to follow in terms of links, what to do with static resources such as images, how to handle relative links, etc. It also does a very good job of mining pages which are generated dynamically, such as those served by CGI or ASP.
It's been around for many years in the 'nix world but executables compiled for Windows are readily available.
You would need to kick it off from .NET using Process.Start but you could then pipe the results into multiple files (which mimic the original website structure), a single file, or into memory by capturing standard output. Then you can do subsequent analysis such as extracting HREF HTML elements (if it is only links you are interested in) or grabbing the sort of table data evident in the link you provide in your question.
I realise this is not a 'pure' .NET solution but the power WGET offers more than compensates for this, in my opinion. I have used it myself in the past, in this way, for exactly the sort of thing I think you are trying to do.
I recommend to use http://watin.org/. This is much simpler than wget :-)
I need get the html code this site (with C#):
http://urbs-web.curitiba.pr.gov.br/centro/defmapalinhas.asp?l=n (only works with IE8)
Using the WebClient class, or HttpWebResquest, or any other library, I do not have access to the html code generated dynamically.
So my only solution (I guess) would be to use the WebBrowser Control (WPF).
I was trying and trying, using mshtml.HTMLDocument and SHDocVw.IWebBrowser2
but it is a mess, I can not find what I want on it
it seems there are many "iframe", and inside there are more "iframe".
I do not know, I tried:
IHTMLElementCollection elcol = htmlDoc.getElementsByTagName("iframe");
var test = htmlDoc.getElementsByTagName("HTML");
var test2 = doc.all;
but had no progress, does anyone know how to help me?
Observation / trivia: This is the site that shows where all bus pass in my city. This site is horrible, and only works in IE8 has serious problems. I would like to use this information to try to create a better service, using google maps or bing maps posteriorly.
The site that I was trying to get the information is no longer available, the idea to get dynamic html source code was abandoned and I cannot found the solution using a WebBrowser Control for WPF.
I believe that today there are other ways to solve this problem.
You need to use the "Frames" object in the WebBrowser control, this object collection will return all frames and iframes if I recall correctly, and you need to look at the frames collection for each newly discovered frame you find on the page, get me? So, it’s like a recursive discovery loop that you need to run, you add each frame you find to your array or collection, and for each "unsearched" frame, you must look at that frames ".Frames" collection (they will all have a .Count etc, just a typical collection) and you do this for every newly discovered frame that you find, until of course, there are no longer any newly discovered frames that haven't had their ".Frames" collection searched.
So, the function, if done as per above, will allow for infinitely nested frames to be discovered, as I've done this in a VB6 project (I'm happy to give you the source for it if you would like it). However, the nesting is not preserved in my example, but that is ok since the nesting structure isn't important and you should figure out which was what by the order of the frames that are added to the collection since the order is related to the hierarchy of the frames being added.
Once you do that, getting the html source on this is pretty straight forward and I’m sure you know how to do, probably a .DocumentText depending on the version of the WB control you are using.
Also, you say it is not possible to use the HTTP clients to directly grab the source code? I must disagree, since once you have the frame objects, you can get the URLs from each frame object and do a URL2String type call to get the URL and turn it into a string from any httpclient-like class or framework. The only way it may be prevented on their behalf if if they accept requests only from a particular referrer (ie: the referrer must be from their domain name on some of their files etc), or the USER_AGENT where if it isn't one of the specified browsers, then it is technically possible that they will reject and not return data, unlikely but possible.
However, both referrer and user_agent can be changed in the httpclient you are using, so if they are imposing limits based on this sort of stuff, you can spoof them very easily and give them the data that they expect. Once again, this is low probability stuff, but it is possible they may have set things up this way especially if their data is proprietary.
PS: My first visit to the site ended up in IE crashing and reopening that tab :), terrible site I agree.
I want to make a program that will simulate a user browsing a site and clicking on links. Cookies and javascript have to be enabled. I've successfully done this in python, but I want to write it an compilable language (python ide's don't cut it). The links on the site are generated with javascript and are dynamic. With python I used PAMIE (third party module that uses win32com) to launch an instance of Internet explorer, scrape the generated html for the links, then navigate to one of them. The point is for the whole process to be transparent to the server. What's the best (compilable) language and method to do this? I was thinking C# with WebBrowser control but I don't want to spend a lot of time learning something if it isn't going to work. Any kind help is appreciated!
You might want to look at the automated testing via browser suites:
http://www.teknologika.com/blog/the-holy-grail-net-automated-web-gui-testing-for-internet-explorer/
http://watin.sourceforge.net/
I wrote a blog post on this awhile back: Web scraping in .NET. That discusses cookies but not JavaScript; I don't know if that would require additional coding.
Might be worth having a look at selenium .
We use it for web testing in a C# asp.net envirnorment.
The documentation isn't to bad
We are looking for some code/component that can create a flow-chart (image) dynamically, preferably in .NET/C# (although a Silverlight/Flash-component that takes a XML/JSON-feed will also be fine).
For example we have a (business) quote that goes through te following steps before it becomes final:
Requested -> Pending -> Ready for revision -> Under revision -> Final
And as an extra step there is the possibility to go from 'Under revision' back to 'Pending'.
So the component/code should draw something like this (where 'Under revision' would be the active status for this quote):
Example chart http://www.wowtah.nl/flowchart-example.gif
The reason that we are not just creating static GIF-images (and load the correct one on demand) is that these steps can vary per customer implementation of our product. So we're looking for a way of dynamically show the user the workflow steps that are configured for them.
Any help would be greatly appreciated!
Take a look at Microsoft MSAGL
I built a workflow solution a while back and evaluated a number of diagramming controls, including the MindFusion control. I settled on the Syncfusion diagram control, primarily for its ease of use for an end user (especially when drawing connections).
I'm using the WPF edition, but they make editions for ASP.Net and WinForms. It has methods for exporting to images.
These are some of the components that I can remember evaluating; I'd recommend giving them a shot and seeing which you like best.
Syncfusion,
NWoods,
yWorks,
Nevron,
EasyDiagram
MindFusion looks like they have some good diagramming controls that may work for you:
http://www.mindfusion.eu/diagramming.html
In the meantime there are also open source diagramming libraries that you can find on Codeplex and Google code.
A very deep one with many features and very flexible is
http://nshape.codeplex.com/
Perhaps easier to program but more limited in scope
http://www.dalssoft.com/diagram/