How to automate in-browser actions - browser

very out of my element here but trying to find a solution. Currently, I am stuck with only one option to get a CSV file of some data, and that is by clicking on an EXPORT button from the Web UI of a webapp my company uses.
This really puts a kink in the works for automating and programatically setting everything up. How can I devise a script or maybe a plugin or something that can automatically do this action for me (clicking the export button) and be able to also schedule the action. Any ideas?

You can try to use AutoHotKey. It's a tool to automate UI in general.
Or you could try Selenium + Geckodriver. It is in browser automation, but I don't know if Export is supported.

Related

Handling file download popup of chromium browsers using VBA

I'm using Selenium with VBA and Microsoft Edge to collect information, and download some files from a webpage. Everything works great except for the downloading part.
On this example site: https://file-examples.com/index.php/sample-documents-download/sample-doc-download/, Code like
oWebDriver.FindElementByXPath("//a[#href=""https://file-examples-com.github.io/uploads/2017/02/file-sample_100kB.doc""]").Click
will result in a popup like this:
Unfortunately, it is not possible to simply change the browser's preferences in my case, because the macro will be running on a machine with limited authorization and the following setting can not be changed:
The last option can be translated to: "Ask for the storage location with every download" and it is locked.
It seems that the "Save As" popup in the first screenshot can't be accessed, neither with Selenium nor with SendKeys.
So the only option seems to be using the Windows API with VBA to somehow automate this step, however, even so, it seems to be impossible to get a handle on this pesky popup. I tried finding the window with Spy++ and it doesn't seem to show up as a separate window:
The only solution I can now think of is getting the window size of the parent Edge browser window, navigating the mouse to the approximate position of the "Save As" button, and clicking it there using VBA and the Windows API. Obviously, This is not a great solution, as it would be quite frail and can easily break with the smallest misalignment.
Is there any other way to automate this step that doesn't require moving the mouse and automating the "manual" clicking, using only VBA with Selenium?
Selenium only works for browser web page automation. The pop-up is not a part of the wab page so Selenium will not be able to recognize it.
And I think any setting in Selenium including "download.prompt_for_download" won't have effect. The pop-up is controlled by the browser setting, and the browser setting is controlled by your group policy, you can't override it with Selenium settings.
I think the only way is to use some 3rd party UI automation library to click that option along with Selenium, just like what you said in the question.

How to launch windows applications from a website

I want to know if it's possible to launch windows applications from a website. If it is possible, how? Sort of like battlelog for battlefield, when a button is pushed it opens an application.
Edit: This is for personal use
Try this:
Make each button be a link to download a company template file for the given application. For example, the "Excel" button would download and the user should be prompted to open it with Excel.
For instance, try clicking one of the links here:
http://www.google.com/#sclient=psy&hl=en&q=template+filetype:xls
Linking to static files on the web server should be sufficient, so long as your server sends the correct MIME-Type or Content-Type.
HOPE it helps!
Take a look at this thread. it should point you in the right direction. In short you can do this in IE using ActiveX objects. But I must warn you that it is a very bad idea

Automate right click save as in IE, Chrome and Firefox?

Does anybody know a way I can automate the right click and save as actions for IE, Chrome and Firefox?
I am doing some selenium work using Maven and need to be able to download some files but I am unable to do this as the save as windows cannot (to my knowledge) be automated by Selenium as they are OS dialogs.
I disagree with Bob, Bill and the author of the article that is linked to in the other answer.
Downloads can be automated. The downloaded file can be meaningfully verified. In simplest case you can compare the contents of downloaded file with an existing exemplary file.
(Disclaimer: the next paragraph is about a tool which I am affiliated with).
For example if you use RIATest for automation you can automate the right click, then automate the OS dialog, then wait until the download is finished and verify the content of the downloaded file.

What general approach can I take to parse the contents of a website?

Say someone else has a website generated by JavaScript, so I can't go look at the source and read what should be on the screen. How can I grab the text on the screen so I can feed it into another program? Also, how can I write a program that automatically clicks on radio buttons, links, etc. that satisfy certain criteria?
You can write a web scraping tool in Perl or Python. Or, you can use existing tools and frameworks to achieve that.
Check out Scrapy, an open-source tool written in Python.
Take a look at Selenium too.
To parse dynamic content you could see the javascript source and get that same content the same way the webpage is getting it. (ie. replicating ajax calls and such)
If you want to submit data (not actually click on the elements) as if it were clicked/edited/selected you could also send a request containing the same data that the server is expecting by using some HTTP library, like CURL. See an example here.
If you need to handle content generated by script, then your first problem is to cause the script to execute. Further, the script will want to generate the content into a DOM. That means you need to have a DOM, and a script engine, and probably HTTP access to the Internet, and XML handling, etc.
If that sounds a lot like a web browser, then you're listening.
What you basically need is a web browser that you can control from a program. You'll need to be able to tell it to browse to a page, click buttons and links, etc., then you'll need to read back the resulting DOM.
Only then will you need to parse the page.
If you're in the Microsoft world, then you can use the WebBrowser control. There are several forms of this, and they all amount to the same thing: you can have Internet Explorer run inside of your program, and your program can control it.
I understand there are other browsers that can be controlled from a program, but since I don't know their details, I'll wait for someone else to tell us both.

programmatically clicking the "Image Submit"

I am trying to make an app on .NET to click the "submit" button on a web page. Basically the app is filling out forms and clicking submit. Most of the pages work but some of them they have a graphic like "NEXT" and "PREVIOUS". There is no submit type control on the web page. The source code that I can see doesnt show that there is a JS to call or anything. The web source just looks like its a graphic, and nothing else.
I am trying to find out how I would click on the graphic or find out what its doing like calling javascript or something so I can emulate it.
Does anyone have any ideas?
The page could be adding the click event handler somewhere else in javascript. If you are looking for a automation solution Watin would be another program to look at to automate firefox or IE using .Net.
Do you need to do it in .NET? I write simple automation programs like this all the time in Sikuli, it's very good for this sort of thing.

Resources