Autotest with Selenium on Raspberry Pi
Looks like if you can install Linux on a thing, you can run Selenium on it
Having Kubuntu (or other Ubuntu derivative) installed to a Raspberry Pi 4, it is actually pretty easy to run Selenium on it.
Instructions
In order to do this, you must have python3 and preferrably have python3-venv installed, and selenium, too:
sudo apt install python3 python3-venv python3-selenium
I prefer running python3 scripts in virtual environment, so let’s create dir for tests and venv in it:
mkdir autotests; cd autotests
python3 -m venv venv
. venv/bin/activate
Now, let’s install latest Selenium into it:
pip3 install -U selenium
Put a script into this directory, e.g. this one which I’ve got from a Skillshare class:
vi scrape_table.py
File contents:
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('https://en.wikipedia.org/wiki/List_of_European_Union_member_states_by_GDP_growth')
time.sleep(1)
table = driver.find_element_by_xpath("//table[@class='wikitable sortable jquery-tablesorter']")
for row in table.find_elements_by_xpath(".//tr"):
for td in row.find_elements_by_xpath(".//td"):
print(td.text)
print("\n")
Now, run the script, and voila, it runs on Raspberry Pi!
python3 scrape_table.py