Exemplo n.º 1
0
def select_proceso_type(abbrev, option2id, wd):
    name = abbrev2name[abbrev]
    i = option2id[name]
    option_name = wd.find_element_by_xpath(BUILD_PROCSO_OPTION(i)).text
    assert name == option_name
    click_it(wd, PROCESO_TYPE_SELECTOR)
    click_it(wd, BUILD_PROCSO_OPTION(i))
Exemplo n.º 2
0
def prepare_for_screenshot(wd):
    click_it(wd, FIRST_ROW_POPUP)
    wd.switch_to.frame(0)
    click_it(wd, POPUP_REFRESH_BUTTON)
    # wd.switch_to.frame(0)
    html = wd.page_source
    soup = BeautifulSoup(html, features="html.parser")
    # df = pandas.read_html(html)[0]
    title = soup.find_all("title")[0].text
    assert "Proceso" in title
    name = "-".join([s for s in title.split(" ") if len(s) > 0])
    return name
Exemplo n.º 3
0
def dump_proceso_table(wd):
    click_it(wd, FIRST_ROW_POPUP)
    wd.switch_to.frame(0)
    click_it(wd, POPUP_REFRESH_BUTTON)
    # wd.switch_to.frame(0)
    html = wd.page_source
    soup = BeautifulSoup(html, features="html.parser")
    # df = pandas.read_html(html)[0]
    title = soup.find_all("title")[0].text
    assert "Proceso" in title
    name = "-".join([s for s in title.split(" ") if len(s) > 0])
    wd.switch_to.parent_frame()
    return {"name": name, "html": html}
Exemplo n.º 4
0
def fire_search(base_url, search_id, wd):
    wd.get(base_url)
    click_it(wd, BUSCADOR_DE_PROCESOS)

    option2id = build_option2id(wd)
    abbrev, number = search_id.split("-")

    select_proceso_type(abbrev, option2id, wd)

    enter_keyboard_input(wd, DESDE, "01/01/2000")
    enter_keyboard_input(wd, HASTA, "01/01/2021")
    enter_keyboard_input(wd,
                         SEARCH_INPUT,
                         number,
                         clear_it=True,
                         press_enter=True)
Exemplo n.º 5
0
co = Options()
# chrome_options.add_argument("--headless")
co.add_argument("--no-sandbox")
co.add_argument("--window-size=1200x800")
user_data_dir = os.environ[
    "HOME"] + "/.config/google-chrome"  # TODO: this only works with ubuntu/linux
co.add_argument(f"--user-data-dir={user_data_dir}")
co.add_experimental_option("useAutomationExtension", False)
co.add_experimental_option("excludeSwitches", ["enable-automation"])
executable = '/usr/bin/chromedriver'
wd = webdriver.Chrome(options=co, executable_path=executable)
wd.implicitly_wait(10)  # seconds

wd.get("https://www.youtube.com")
search_form = '//*[@id="search-form"]'
click_it(wd, search_form)

search_full = '/html/body/ytd-app/div/div/ytd-masthead/div[3]/div[2]/ytd-searchbox/form/div/div[1]/input'  # only got it working with full xpath
video_title = '//*[@id="video-title"]/yt-formatted-string'

time_to_play_video = 2

search_strings = [
    "wtf", "hi andres!", "cholombianos", "tatiana patita", "pinguin"
]
for search_string in search_strings:
    enter_keyboard_input(wd, search_full, search_string, clear_it=True)
    click_it(wd, video_title)
    sleep(time_to_play_video)

wd.quit()