Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we use Selenium Webdriver in colab.research.google.com?

I want to use Selenium Webdriver of Chrome in colab.research.google.com for fast processing. I was able to install Selenium using !pip install selenium but the webdriver of chrome needs a path to webdriverChrome.exe. How am I suppose to use it?

P.S.- colab.research.google.com is an online platform which provides GPU for fast computational problems related to deep learning. Please refrain from solutions such as webdriver.Chrome(path).

like image 706
john mich Avatar asked Jun 26 '18 15:06

john mich


People also ask

Can I use Selenium on Google?

We can click on Google search with Selenium webdriver. First of all we need to identify the search edit box with help of any of the locators like id, class,name, xpath or css. Then we will input some text with the sendKeys() method.

What is Selenium WebDriver for?

Selenium WebDriver is a web framework that permits you to execute cross-browser tests. This tool is used for automating web-based application testing to verify that it performs expectedly. Selenium WebDriver allows you to choose a programming language to create test scripts.

Can I run Selenium on Jupyter notebook?

We've seen in past how to install and run Selenium with Python, in this guide we will try to do the same in Jupyter Notebook on WSL2. The instructions should be same for both WSL2 and Ubuntu.


1 Answers

You can do it by installing the chromium webdriver and adjusting some options such that it does not crash in google colab:

!pip install selenium !apt-get update # to update ubuntu to correctly run apt install !apt install chromium-chromedriver !cp /usr/lib/chromium-browser/chromedriver /usr/bin import sys sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver') from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') wd = webdriver.Chrome('chromedriver',chrome_options=chrome_options) wd.get("https://www.webite-url.com") 
like image 120
Thomas Avatar answered Oct 18 '22 17:10

Thomas