Exemplo n.º 1
0
def browser_fixture():
    chrome_driver = ChromeDriverDownloader()
    driver_path = chrome_driver.download_and_install()
    driver = webdriver.Chrome(
        executable_path=driver_path[0])
    yield driver
    driver.quit()
Exemplo n.º 2
0
 def setup_class(cls):
     cur_path = pathlib.Path(__file__).parent
     cls.file = open(f"{cur_path}\\..\\..\\test_input_data\\qa.json")
     cls.data_gen = [json.load(cls.file)]
     chrome_driver = ChromeDriverDownloader()
     driver_path = chrome_driver.download_and_install()
     cls.driver = webdriver.Chrome(executable_path=driver_path[0])
     session_email = cls.data_gen[0]["session_email"]
     session_password = cls.data_gen[0]["session_password"]
     page = SignInSearchHelper(cls.driver)
     common = CommonSearchHelper(cls.driver)
     page.go_to_sign_in_page()
     page.type_sign_in_email(session_email)
     page.type_sign_in_password(session_password)
     page.click_sign_in_btn()
     common.click_addresses()
     return cls.driver, cls.data_gen
def generate_cookie(cookie_path):
    gdd = ChromeDriverDownloader()
    chrome_driver = gdd.download_and_install()

    # TODO: load previous cookies so it does not ask to re verify using an
    # email code each time
    driver = webdriver.Chrome(executable_path=chrome_driver[1])

    driver.get('https://www.humblebundle.com/login')

    while '/home/library' not in driver.current_url:
        # Waiting for the user to login
        time.sleep(.25)

    cookie_str = _get_cookie_str(driver)
    with open(cookie_path, 'w') as f:
        f.write(cookie_str)

    logger.info("Saved cookies to " + cookie_path)

    driver.quit()
Exemplo n.º 4
0
def get_chrome_driver():
    home = os.path.expanduser('~')
    driverpath = os.path.join(home, 'browser-drivers')
    if not os.path.exists(driverpath):
        os.mkdir(driverpath)
        sys.path.insert(0, str(Path(driverpath).absolute()))
    else:
        for filename in os.listdir(driverpath):
            if filename == 'chromedriver.exe':
                filepath = os.path.join(driverpath, filename)
                return filepath

    chrome_path = shutil.which("chromedriver") or shutil.which(
        "chromedriver.exe")
    if chrome_path:
        return chrome_path

    try:
        gdd = ChromeDriverDownloader(driverpath, driverpath)
        _, sym_path = gdd.download_and_install()
        return sym_path
    except OSError:
        return None
Exemplo n.º 5
0
# In Docker images, install webdrivers for selenium to use Chromium/Firefox.

from webdriverdownloader import ChromeDriverDownloader, GeckoDriverDownloader

# install chrom(e|ium) webdriver to match default Linux chromium major version
cdd = ChromeDriverDownloader()
chromiumdriver, chromiumpath = cdd.download_and_install("87.0.4280.20")
print(chromiumdriver, chromiumpath)

# install firefox webdriver
gdd = GeckoDriverDownloader()
geckodriver, geckopath = gdd.download_and_install("v0.23.0")
print(geckodriver, geckopath)

# (former iteration -- was called install_driver.py)
# Install the proper driver for the browser that selenium will drive headlessly.
# import argparse

# parser = argparse.ArgumentParser(description='set up')
# parser.add_argument('browser', type=str,
#                     help='the browser to use in headless sessions')
# args = parser.parse_args()
# print(args)
# browser = args.browser.lower()

# if browser == 'chrome':
#     from webdriver_manager.chrome import ChromeDriverManager
#     chromepath = ChromeDriverManager().install()
#     print(chromepath)
# elif browser == 'chromium':
#     # from webdriver_chromium_edit import ChromiumDriverManager
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options
import getpass
import multiprocessing
import random
from webdriverdownloader import ChromeDriverDownloader
import logging

logging.basicConfig(filename='logfile.log', level=logging.WARNING)
SHOW_URL = "https://dlive.tv/ghostpolitics"

gdd = ChromeDriverDownloader()
gdd.download_and_install()

browser_options = Options()
#chrome_options.add_argument('--headless')
width = 1920
height = 1080
browser_options.add_argument('window-size={width}x{height}')
#'/usr/local/bin/chromedriver',
driver = webdriver.Chrome(options=browser_options)
CURRENTLY_STREAMING = False
spamproc = None
checkproc = None


def check_if_streaming():
    global CURRENTLY_STREAMING
]

FFLOGS_TARGET_ZONE_ID = 887   # The Epic of Alexander
FFLOGS_TARGET_BOSS_ID = 1050  # The Epic of Alexander
FFLOGS_API_FIGHT_URL = (
    'https://www.fflogs.com/v1/report/fights/{report_id}?api_key={api_key}'
)
FFLOGS_DPS_URL = (
    'https://www.fflogs.com/reports/{report_id}/#boss={boss_id}&difficulty=100'
)
FFLOGS_URL_DAMAGE_DONE_AND_PHASE_QUERY = '&type=damage-done&phase={phase_num}'
FFLOGS_URL_FIGHT_QUERY = '&fight={fight_id}'

base_dir = os.path.dirname(os.path.abspath(__file__))
bin_dir = os.sep.join([base_dir, 'bin'])
ChromeDriverDownloader(download_root=base_dir, link_path=bin_dir) \
    .download_and_install()
os.environ['PATH'] = os.pathsep.join([bin_dir, os.environ.get('PATH', '')])


class Actor:
    '''
    Actor: プレイヤーなどのキャラクターを表すクラス
    '''

    def __init__(self, name, job, phase_count):
        self.name = name
        self.job = job
        self.dps = [0] * phase_count

    def __lt__(self, other):
        # self < other
Exemplo n.º 8
0
#This can be used as follows within a notebook
from webdriverdownloader import ChromeDriverDownloader

cdd = ChromeDriverDownloader()
chromedriver, chromebin = cdd.download_and_install()

#If required, the path to the drive can be set explicitly:
from selenium import webdriver

browser = webdriver.Chrome(executable_path=chromebin / chromedriver)
Exemplo n.º 9
0
def download_chromedriver():
    chd = ChromeDriverDownloader()
    chd.download_and_install()