Download file with Selenium, Python 3 - python-3.x

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.

Related

Activating / clicking a browser extension in Firefox with Selenium in Python 3

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.

Is there any way to open a new tab using a webbrowser module of python in colab?

import webbrowser
webbrowser.open_new_tab('www.google.com')
I am using Google-colaboratory and getting False as a output. Instead of that, it should open a new tab with url of Google. It's working well in python 3.7 as well as in PyCharm.
I know that program written in colab runs on google cloud and there's nothing like browser in google cloud.
Is there any other way to do this in google-colab except by using selenium tools?
Thanks in Advance!
Sometimes if the lines of code required to open a webpage need to be enclosed in conditional statements or a loop or any situation in which %%javascript cannot be written as first line of the cell, use this code
from IPython.display import Javascript
def open_web():
url = 'https://www.google.com/'
display(Javascript('window.open("{url}");'.format(url=url)))
No, there is no way to control your browser via Python's webbrowser package in Colab. The reason is that your browser is running on your local machine, while the Python code in Colab is running on a virtual machine in Google Cloud.
The only way you can open a new tab via Colab is by injecting javascript code that will cause your browser to do so; for example:
%%javascript
window.open('https://colab.research.google.com', '_blank');
But be aware that your browser may block windows opened in this manner.

Posting pictures to Instagram using headless Selenium

I would like to upload a picture to Instagram using headless selenium, and I am running my app on an Ubuntu 18.04 server.
For the selenium part I have used this solution and it works perfectly, however I cannot use autoit as it is Windows only, and even if it weren't, I'm not so sure I could still use it as I am going headless.
Sending the image path directly through selenium is not an option either, as Instagram doesn't have rendered file input fields. It probably just generates one when the post button is clicked but never adds it to the DOM.
Is there a way to remake what the solution I've linked above does without autoit?

Editing already open website Selenium

I want to mimic mouse clicks on buttons etc. on a website which is already open in a browser(e.g. Chrome). Do you guys know if I can do this with Selenium? Or do you guys know how I can do this in general?
No, you have to launch the browser with selenium by initializing the driver. Selenium is proxying the browser so that your code can control it.
http://selenium-python.readthedocs.io/getting-started.html

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.

Resources