I have a very strange request that might upset some of you, anyway I want to write text or numbers in the website using C# or wpf software.
What I want is I pass string or number to the website when I press for example F11 on the keyboard and that number or string can be from a textbox.
Assume the following is Grid on a website:
Now I want to pass 0.01233 from textbox, to the highlighted cell in the website using c#.
Can anyone please how this can be achieved or at least guide me which direction I should go and achieve this.
Please Note I am not a developer of website and I have no control on website, I cannot write script on website
I've done something like this before, though I can't seem to find my old code. WPF has a WebBrowser control. You can use the Document property to access elements of the webpage an (if I recall correctly) execute scripts assosiated with those elements.
Of course it goes without saying that this would be a bodge at best, since any change made to the website could break your code.
Also, this forces you to use the WPF WebBrowser instead of your browser of choice.
Related
In BluePrism it is possible to spy buttons, fields etc. of any windows application and then click those buttons automatically. For example, if you look at the screenshot you can see the attributes of the calculator's button "1" as spied in the Win32-mode (there are also HTML-, Accessibility-, Region- and UI Automation-modes) by which BluePrism will be able to identify and click the according button. Furthermore, BluePrim is compatible with C# and I wonder whether (and how) I could also get those attributes via C# instead or at least use the spied attributes as can be seen on the screenshot to press the same button with C# instead?
EDIT:
It would be highly appreciated if someone could provide the C# code for pressing the calculator's button "1" to get me started (I'm a C# newbie :-) Thanks!
You do not need C# for that, you can just use a Reader stage and action Get AA Attribute or Get Window Attribute.
EDIT:
But if you really want to do it using .NET only, have a look at UI Automation or Active Accessibility Automation (older one)
This seems like a nice example.
You will also find a tool called Inspect.exe very handy to spy elements without using BP. This
You can use the Application Model that you just spied, put it in a navigate stage in your object, then select Click Mouse Centre as the action. This will result in the button you have spied being clicked. Generally, to use Sendkeys is with C# syntax, i.e. use the root element (root element and top of list in Application Modeller tree) and select Global SendKeys as the action inside a navigate stage. In the Text input field you can enter your C# sendkey code, like for example for Ctrl + Alt + Delete use: "^%{DELETE}". I think this is what you may be looking for? Otherwise, if I understand correctly, you might be looking to use a C# code-stage inside BP to pass sendkeys to an application attached to a BP process, which would possibly involve referencing each and every attribute of the host application in C# and then using (for example) the C# Enum properties of each keyboard key, etc... this would be a massively redundant exercise since BP already provides the functionality inside the navigate stage as explained above.
I tried WebBrowser but any solution related to WebBrowser I find uses the exact same codes, WebBrowser.DrawToBitmap
Problem with that is, it gives out inaccurate results depending on URL, to what page actually would look like, sometimes even blank pages.
So I am looking for any alternate solution to WebBrowser if there is any.
It needs to run in background, as in not open any browser on screen, render it in background with all scripts and get an image.
If I understand what you're trying to do, you might be interested in a framework called PhantomJS, which is a WebKit "browser" engine which runs the pages without visually rendering them. It can be used to capture screens.
Now this technique requires JavaScript, but there is something called Selenium WebDriver to help you wrapping that. Users here at SO posted a simple example and this comment looks useful as it contains the list of required Packages.
[edit] It is a requirement that the webpage spawn and open in IE and allow user manual interaction after the programmatic actions have completed.[/edit]
I've seen a lot of code examples online about opening webpages or filling in webpage textboxes and getting a return value without ever opening them visibly.
I would like to open a webpage in IE, fill in a few textbox buttons
and then click the submit button and view the results visibly.
I am able to do this with a dll called Selenium, but I do not want to use a 3rd party application and it seems that WebBrowser() should be able to do this?
I can post my failed code examples if that would help.
Thanks.
Maybe this qould fit better as a comment, but I don't have enoigh reputation.
Do you know how HTTP-Forms work?
It would probably be easier to send a HTTP-Request to the target of the form you want to fill, including the parameters you would like to fill into the form.
So you don't need any WebBrowser or similar, just a simple HttpWebRequest object, where you specity the target, the method (very likely POST) and the data you'd like to send.
You can use the webbrowser control in Winforms. It is possible to access every DOM object of the website using the control. No need to open the IE externally.
You just need to specify the webbrowser URL as your link.
Then, fill the textboxes with code,
BrowserID.Document.GetElementById("TextboxID").SetAttribute("Value", "NewVaue")
Also, you can click on the button using InvokeMember("click").
There are lots of stuff using WebBrowser. You can learn it here.
I am doing a project in C# where users may specify an equation and have the app solve it. I want to use the Math Input Panel for the user to specify the equation, but the problem is that I dont know how to render the equation in the WPF app after the user presses Insert, since normal textboxes and textblocks wont display it.
I have read up thoroughly on how I need to do this, but have come up short. I realize that I need my app to support MathML so that the equation can be displayed, but that's just it... How do I make my app support MathML so that I can display it?!
So basically the user will see the equation that he has just written with the Math Input panel, and then I want to convert (behind the scenes) the equation to MathML so that I can write a parser to solve it.
Thanks in advance... I'm really desperate ;)
There will be, see Murray's post about the rich edit control in windows 8
http://blogs.msdn.com/b/murrays/archive/2012/03/03/richedit-8-0-preview.aspx
The other thing I’d like to point out in this post is that the new
RichEdit supports math editing and display!
I just want to post my answer for clearity.
I read somewhere that you can display an equation using a browser control, but Internet Explorer doesn't support MathML. For this reason, I tried to figure out if there was some kind of other browser control (like a firefox version) that i could use. After trying and failing at that, I stumbled upon MathPlayer from www.descci.com.
MathPlayer adds MathML support to IE en because of that, I was able to render equations in WPF using the browser control and style it using CSS.
I want to be able to use the .NET WebBrowserControl to record and repeat user actions to automate the collection and retrieval of text from web pages for a data extraction tool that I'm building, but am unsure about how to best approach this.
I specifically want to use the .NET WebBrowserControl as it can be embedded in a .NET form and also used within a server side process without a UI. I'm aware that there are other means of recording and repeating user actions such as Selenium, but for now I am interested in a solution around the web browser control (just to keep answers focused).
Actions to be recorded are those such as button clicks, drop down list selection, link clicks etc.
Potential solutions I have looked at so far:
(Please correct me if my notes based on brief evaluations are wrong)
iMacro (doesn't appear to have a component that can be used within a project, to record user actions, rather the GUI has to be used).
WaitN - Good for programmatic play back - but no recording facility that can be hooked up to the web browser control?
I'm presuming this is possible as services like Mozenda appear to make use of the WebBrowserControl, or some IE like version based on mshtml.dll.
Are there any other options I can look at?
Any insight would be appreciated.
yap, as in Mozenda ,when user create any action like goto mainpage>click on images>download image etc... the XPath is recorded with the each page url into XML file. So, use self learning algorithm to implement such kind of XML better way than mozenda.
i have developed one application using JSOUP and Regular Expression Parsing works same as mozenda do. i created the configuration file which contains the XPath of all the items you want . Which works great for me.
Hope this helps,