import os
from time import sleep, time

from src.framework.common import file_abspath

from selenium import webdriver
from selenium.webdriver.chrome import service
from selenium.webdriver.chrome.webdriver import WebDriver

# web_driver_path = os.path.join(
#     "./chromedriver")
service = webdriver.chrome.service.Service(file_abspath() + "/tools/chromedriver.exe")
service.start()


def get_app_driver(PATH_TO_BINARY_APP):
    driver: WebDriver = webdriver.remote.webdriver.WebDriver(
        command_executor=service.service_url,
        desired_capabilities={
            'browserName': 'chrome',
            'goog:chromeOptions': {
                'args': [],
                'binary': PATH_TO_BINARY_APP,
                'extensions': [],
                'windowTypes': ['webview']},
            'platform': 'ANY',
            'version': ''},
        browser_profile=None,
        proxy=None,
        keep_alive=False)
    sleep(5)
    return driver


if __name__ == '__main__':
    get_app_driver()
    # driver = get_app_driver(PATH_TO_BINARY_APP)
    # driver.find_element_by_id("rc-tabs-0-tab-2").click()
