#!/usr/bin/python3
# -*- coding: utf-8 -*-

import apt
import os.path
from selenium import webdriver

if __name__ == '__main__':
    options = webdriver.firefox.options.Options()
    options.binary_location = "/usr/bin/firefox"
    options.add_argument("-headless")
    driver = webdriver.Firefox(options=options)
    version = driver.capabilities['browserVersion']

    package = apt.Cache()['firefox']
    assert package.installed.version.split('+')[0].split('~')[0] == version

    tests_dir = os.path.dirname(os.path.realpath(__file__))
    driver.get("file://{}/data/firefox-version.html".format(tests_dir))
    assert version.startswith(driver.find_element_by_id("firefox_version").text)

    driver.quit()
