# From https://stackoverflow.com/questions/25827160/importing-correctly-with-pytest
# Change current working directory so test case can find the source files
import sys, os

os.chdir(os.path.dirname(__file__))
# sys.path.append(os.path.realpath(os.path.dirname(__file__)+"/src/test"))

from utils_test import get_driver
import time


def test_theme_button():
    """
    Function:
        test_theme_button
    Description:
        Tests that the theme is properly switched
    """
    print(sys.path)
    driver = get_driver()

    toggle_button = driver.find_element_by_class_name("switch")
    theme = driver.find_element_by_id("theme")

    current_theme = str(theme.get_attribute("href")).split("/")
    current_theme = current_theme[-1]
    assert current_theme == "light.css"

    for i in range(10):
        toggle_button.click()
        current_theme = str(theme.get_attribute("href")).split("/")
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == "dark.css"

        toggle_button.click()
        current_theme = str(theme.get_attribute("href")).split("/")
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == "light.css"

    driver.close()

d1d501342d1a76d7815f8a85f3bc2749016deb6b
<mask token>

<mask token>


def test_theme_button():
    """
    Function:
        test_theme_button
    Description:
        Tests that the theme is properly switched
    """
    print(sys.path)
    driver = get_driver()
    toggle_button = driver.find_element_by_class_name('switch')
    theme = driver.find_element_by_id('theme')
    current_theme = str(theme.get_attribute('href')).split('/')
    current_theme = current_theme[-1]
    assert current_theme == 'light.css'
    for i in range(10):
        toggle_button.click()
        current_theme = str(theme.get_attribute('href')).split('/')
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == 'dark.css'
        toggle_button.click()
        current_theme = str(theme.get_attribute('href')).split('/')
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == 'light.css'
    driver.close()

<mask token>
os.chdir(os.path.dirname(__file__))
<mask token>


def test_theme_button():
    """
    Function:
        test_theme_button
    Description:
        Tests that the theme is properly switched
    """
    print(sys.path)
    driver = get_driver()
    toggle_button = driver.find_element_by_class_name('switch')
    theme = driver.find_element_by_id('theme')
    current_theme = str(theme.get_attribute('href')).split('/')
    current_theme = current_theme[-1]
    assert current_theme == 'light.css'
    for i in range(10):
        toggle_button.click()
        current_theme = str(theme.get_attribute('href')).split('/')
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == 'dark.css'
        toggle_button.click()
        current_theme = str(theme.get_attribute('href')).split('/')
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == 'light.css'
    driver.close()

import sys, os
os.chdir(os.path.dirname(__file__))
from utils_test import get_driver
import time


def test_theme_button():
    """
    Function:
        test_theme_button
    Description:
        Tests that the theme is properly switched
    """
    print(sys.path)
    driver = get_driver()
    toggle_button = driver.find_element_by_class_name('switch')
    theme = driver.find_element_by_id('theme')
    current_theme = str(theme.get_attribute('href')).split('/')
    current_theme = current_theme[-1]
    assert current_theme == 'light.css'
    for i in range(10):
        toggle_button.click()
        current_theme = str(theme.get_attribute('href')).split('/')
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == 'dark.css'
        toggle_button.click()
        current_theme = str(theme.get_attribute('href')).split('/')
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == 'light.css'
    driver.close()

# From https://stackoverflow.com/questions/25827160/importing-correctly-with-pytest
# Change current working directory so test case can find the source files
import sys, os

os.chdir(os.path.dirname(__file__))
# sys.path.append(os.path.realpath(os.path.dirname(__file__)+"/src/test"))

from utils_test import get_driver
import time


def test_theme_button():
    """
    Function:
        test_theme_button
    Description:
        Tests that the theme is properly switched
    """
    print(sys.path)
    driver = get_driver()

    toggle_button = driver.find_element_by_class_name("switch")
    theme = driver.find_element_by_id("theme")

    current_theme = str(theme.get_attribute("href")).split("/")
    current_theme = current_theme[-1]
    assert current_theme == "light.css"

    for i in range(10):
        toggle_button.click()
        current_theme = str(theme.get_attribute("href")).split("/")
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == "dark.css"

        toggle_button.click()
        current_theme = str(theme.get_attribute("href")).split("/")
        current_theme = current_theme[-1]
        time.sleep(0.2)
        assert current_theme == "light.css"

    driver.close()
