Browser Remote Control

The setup on this page is done with a fresh ubuntu desktop 20.04 lts installation.

The final script fetches all account balances from the German bank comdirect, and prints the results on the command line.

Firefox runs headless, and is controlled by Selenium with Python.


sudo apt install python3 python3-pip
pip3 install selenium
sudo apt install firefox-geckodriver


from selenium import webdriver
from import WebDriverWait
from selenium.webdriver.common.keys import Keys
from import By
from import expected_conditions as EC
from selenium.webdriver.firefox.options import Options
import time
options = Options()
#options.headless = True
options.headless = False
browser = webdriver.Firefox(options=options)
# Cookies
browserWait = WebDriverWait(browser, 10)
element = browserWait.until(EC.element_to_be_clickable((By.ID, "uc-btn-more-info-banner")))
element = browserWait.until(EC.element_to_be_clickable((By.CLASS_NAME, "uc-save-settings-button")))
# Login
browser.find_element(By.ID, "param1Input").send_keys("<USERID>")
browser.find_element(By.ID, "param3Input").send_keys("<USERPIN>")
browser.find_element(By.ID, "loginAction").click()
# Account Balances
accountTableClass = browser.find_element(By.CLASS_NAME, "table--list")
accountTable = accountTableClass.find_element(By.TAG_NAME, "tbody")
accountRows = accountTable.find_elements(By.TAG_NAME, "tr")
for row in accountRows:
  accountColumns = row.find_elements(By.TAG_NAME, "td")
  print("Name: " + accountColumns[0].text)
  print("Kontostand: " + accountColumns[4].text)
# Logout
browser.find_element(By.ID, "llLink").click()
browserWait.until(EC.text_to_be_present_in_element((By.TAG_NAME, "h1"), "Sie haben sich erfolgreich abgemeldet"))


$ ./
Name: Das tolle Konto
Kontostand: 10,00 €
Name: Ein ganz anderes Konto
Kontostand: 101,12 €

Further Readings