Handling file download popup of chromium browsers using VBA - excel

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.

Related

Is it possible to move Google Chrome tab between windows? got it :)

Edit: Thank you wOxxOm. It worked :)
chrome.tabs.move(XXX,{windowId:YYY, index:ZZZ})
Somehow I did not see the move option :(
I am writing simple Google Chrome web extension and I want to manipulate the tabs and windows. I actually want to be able to move a tab between the windows. The tab will have programatically spawned dynamic page, that I do not want to reload. The windowId is not listed in the modifiable properties chrome.tabs.
Am I missing something or it is currently not supported? What are the workarounds?
p.s. In extreme case also powershell or .Net might be acceptable (I have total control of the target PC). Currently spawning clearly distinguishable iframe over the web pages (background script injected and message listener) but the iframe gets reloaded, which I want to avoid.
p.p.s. Workaround might be to detect the currently active window and spawn new tab in the active window (if required), but this would require to save the page state, close the inactive tab and spown new one in the active window (this should be possible)
p.p.p.s. Main target is Google Chrome, but want it also for Microsoft Edge. Hopefully also for other browsers.
Edit: Thank you wOxxOm. It worked :)
chrome.tabs.move(XXX,{windowId:YYY, index:ZZZ})
Somehow I did not see the move option :(

data extraction from google chrome

I want to get table data from money control website. http://www.moneycontrol.com/financials/infosys/results/consolidated-quarterly-results/IT. I want to use google chrome to open this link and then click on previous years link and get that table too along with the table on that page. I need to click previous years as the url even after clicking previous years remains the same and I cannot directly navigate to it. It is easy with internet explorer but I cannot use it. If there is any other method other than having to click on the link please tell.
Without using a third party library it is only possible to use the Internet Explorer object.
To automate Google Chrome you can try to use Selenium VBA. It's a COM library which creates a Windows COM wrapper for Selenium.
http://florentbr.github.io/SeleniumBasic/
In Google Chrome you have to install a plugin, which helps executing the VBA commands in Chrome.
Download page: http://www.seleniumhq.org/download/

How is the panel displayed when launching Chrome Hangout extension made to be always on top and pinned?

When launching the Chrome Extension Google-Hangouts, a panel initially appears that lists members and a link/button to create a new Hangout.
This panel is initially pinned to the bottom right of the browser window. When pinned like this, it remains always on top as a browser navigation session continues: users can go to different URLs, change tabs, etc. and that panel stays at the bottom right and stays on top of all other windows (or at least on top of the main browser window).
Once it's unpinned, you can drag it around the window, but it no longer stays always on top.
My question is, how was that achieved - what code, or what functions, do i need to call to create that window/panel so that it stays initially pinned and always on top? Is there some binding to some native code that's involved? Some other approach?
If anyone know and can show or explain, i would be hugely grateful as this feature is key to an extension i'm trying to build.
Thanks a lot!
This may not be an answer but to get a clue of what is happening I extracted the crx file to view its content there are a few OS specific files : ace.dll , libace.so and ace. After researching a bit i found this. This is a plugin. Hangouts extension is using ace plugin which is actually running on your desktop(i'm not sure about this). You can check this article
I found this related post: How to build an chrome extension like Google Hangouts
ACE is actually not what makes the window, Chrome has that capability built in, apparently. Even if you don't enable panels, extensions from Google can still make them, provided your OS is capable.

Chrome extension: Multiple tabs in popup window

I was wondering if there is a way to divide the popup window into more than one tab, when each tab functions as a different web page, using chrome extension APIs. Does somebody know if that's possible?
If I can't do that, I thought I will give up the division into separate web pages and just use tabs on the same web page, like UI tabs for example.
Can you suggest a third way?
Browser\Page Action Windows are Windows of type Popup, you cannot add further tabs to the popup window.
As pointed out using some sort of UI Tabs will solve your problem. Let me know if you need more information.

Modal Dialog in Google Chrome Extension

I need a truly modal dialog to run in Google Chrome in Windows using extension, where the dialog doesn't allow users to click on other tabs etc. The search results so far seem to suggest that showModalDialog() doesn't give a true modal dialog, and the jQuery examples (like SimpleModal) don't seem to be able to stop users from accessing the other tabs or the other parts of the browser.
Alerts seem to be be working, so I was wondering if there is any other solution to this problem? Or do I really need to write a modal dialog from scratch using Javascript?
Using the hidden div methods in the web pages is not an option because I can't modify them.
You can simply use the native javascript function confirm
But I don't like when I can't do what I want without good reasons.
Furthermore, the user will can always switch to another Chrome window.
No sort of in tab HTML modal dialog will prevent a user from switching tabs. Even alert will allow users to switch tabs. You may be able to achieve this through a NPAPI plugin though.

Resources