I am writing a script for web automation with SELENIUM and, in theory, I have two options to capture the data I need from the websites I am scraping:
I can let the script extract relevant information from each tag on the result pages.
I can make the script click on the browser extension button in my browser window and let the extension manage the data for me.
I know how to extract information by HTML tag, but when it comes to browser extensions, I have only found instructions how to install / uninstall them with SELENIUM, but no instructions how to "activate" them once they are installed.
I am using Firefox and would be very grateful if you could point me in the right direction.
I was not able to solve this problem in FIREFOX but in CHROME:
I created a browser profile including my extension and a key shortcut to activate it.
I opened that profile when starting the browser with SELENIUM.
I used SELENIUM to navigate to the right URL.
I used pyautogui to press the relevant keys and trigger the file download.
Related
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 can I download a file opened with a blob link via Selenium Chrome? Selenium chrome window shows the player on a black background. I am interested in downloading only with selenium. I use Python 3.6.
Screenshot of Selenium player
https://s8.hostingkartinok.com/uploads/images/2019/05/da6329528e2a577a7aaa0f2a7e613b63.jpg
Selenium cannot work unless there is a web page to insert itself into. Once there is no page, nothing can be automated. Maybe a right-click would be needed here and then maybe a robot for automating outside of the page code.
For a VSCode extension i want open browser within VSCode not externally, wherein i can load some URL (https://developers.redhat.com/)
I tried looking into various options to achieve it in VScode extension, what i came across is with help of webview i.e 'vscode.previewHtml' we can pass html content which would be rendered with in VSCode editor tab, but what i have is url to load. Can pass it to iframe but i can't open it in iframe
Another option is to open it in browser but it opens external browser.
what i need is to open a browser within IDE (VSCode), experience should be similar to what we get for 'vscode.previewHtml'
or as we see in IDEs like eclipse where browser window is opened right inside IDE.
As we can see below
Please give inputs, suggestions
It's possible now without extension. Open command palette (CTRL+P) and search for "Simple Browser: Show".
This is how it looks:
In order to render your html you can use the WebView API:
https://code.visualstudio.com/docs/extensions/webview
Microsoft has an extension in development, Live Preview. I use it to view html codecov reports inside of VSCODE and it at least works for that.
You just search for it in extensions and add it to VSCODE
We are automating chrome extension with sahi.
we have loaded our chrome profile with sahi with extension added on profile.
we weren't able to get dom elements of extensions.
so we are navigating to the url: chrome-extension:/extension_id/popup.html
but sahi doesn't navigate to this url.
but i have read with selenium we are able to get it.
Please help me out, with this automation
I'm not sure, I understand the problem here. But if you want to change some options on chrome. I use this Chromium Command Line Switches to find correct option to set when set browser on 'browser_types.xml`.
For example:
<options>--no-default-browser-check --user-data-dir=$userDir\browser\chrome\profiles\sahi$threadNo --proxy-server=127.0.0.1:$port --disable-popup-blocking --always-authorize-plugins --allow-outdated-plugins --enable-npapi --incognito</options>
Is it possible to make it so I can put the user script that I made on my website and users to instal it simply by clicking on it (on firefox and chrome)?
And if it is possible how do I do it?
And how do I put my user script in chrome manually? In firefox it is simple, I just click on greasemonkey icon and select "new user script". But I simply can't figure out how to do it in chrome and couldn't find the answer online.
For me this looks like a really simple thing to do, but from some reason I can't find the answer by googling. Am I using a bad key word or something? idk.
Is it possible to make it so I can put the user script that I made on
my website and users to instal it simply by clicking on it (on firefox
and chrome)? And if it is possible how do I do it?
Yes. Just insert an ordinary download link such as
Click here to download my script!.
Please note prospective users should have Greasemonkey (Firefox) or Tampermonkey (Chrome) installed. Also, filename of the script should end with .user.js.
Example
And how do I put my user script in chrome manually? In firefox it is
simple, I just click on greasemonkey icon and select "new user
script". But I simply can't figure out how to do it in chrome and
couldn't find the answer online.
Use Tampermonkey.