Last active
October 19, 2022 16:22
-
-
Save dalinaum/c4d2f099c407d932f40d366ecb33587d to your computer and use it in GitHub Desktop.
wtf-selenium.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from selenium import webdriver | |
from selenium.webdriver import ActionChains | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.support.ui import WebDriverWait | |
chrome_path = 'armmac/chromedriver' | |
driver = webdriver.Chrome(chrome_path) | |
driverWait = WebDriverWait(driver, 10) | |
def wait(time=0.1): | |
driver.implicitly_wait(time) | |
def find_id(id): | |
return driver.find_element(By.ID, id) | |
def find_css(selector): | |
return driver.find_element(By.CSS_SELECTOR, selector) | |
def find_text(text): | |
return driver.find_element(By.PARTIAL_LINK_TEXT, text) | |
def find_texts(text): | |
return driver.find_elements(By.PARTIAL_LINK_TEXT, text) | |
def wait_clickable_css(selector): | |
return driverWait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, selector))) | |
def wait_clickable_text(text): | |
return driverWait.until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, text))) | |
driver.get( | |
'https://xxx.co.kr/kr/member-login?rtnUrl=/rsvtn/intro') | |
find_id('id').send_keys('xxx') | |
find_id('pwd').send_keys('xxx') | |
find_css('.submit').click() | |
# 필요없음. 그래도 넣어둠. | |
driverWait.until(EC.text_to_be_present_in_element((By.CSS_SELECTOR, '#wrap > div > div > div > div.tit-area > h2'), '예약')) | |
wait_clickable_css('#wrap > div > div > div > div.slc-area > a:nth-child(1)').click() | |
wait_clickable_text('제네시스').click() | |
# wtf: 가상 드래거 스크롤 | |
wtf_dragger = find_css('#mCSB_1_dragger_vertical') | |
action = ActionChains(driver) | |
action.click_and_hold(wtf_dragger).perform() | |
action.move_by_offset(0, 500).perform() | |
action.release(wtf_dragger).perform() | |
find_text('Drift Level 2').click() | |
wait_clickable_text('10.23').click() | |
wait_clickable_text('9:20').click() | |
# wtf: "참가" 클릭 | |
wait_clickable_css('#ptcprYn_obj > div.btn-square-box > div > div:nth-child(1) > label').click() | |
find_texts('예약하기')[1].click() | |
# driver.quit() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment