# SSAFY automation with Selenium

It's really annoying to do this everyday. Should have done this months ago but here we go.

# Preparation

pip install selenium

Download chromedriver

Place it at C:\Program Files (x86)

from selenium import webdriver
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
1
2
3

# Execution

# Opening browser

driver.get("http://edu.ssafy.com/")
1

# Accessing HTML

id = driver.find_element_by_id("userId")
pwd = driver.find_element_by_id("userPwd")
1
2

.text to access inner text

# Wait until present

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

try:
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_all_elements_located((By.CLASS_NAME, "pop-event-close"))
    )
    print(element)
except:
    print("error 1")
1
2
3
4
5
6
7
8
9
10
11

image-20201230084332885

image-20201230084347679

image-20201230084417048

image-20201230084501571

image-20201230084520051

image-20201230084630281

image-20201230084645199

image-20201230084708242

1 2 5 7 9

image-20201230084824382

# Typing

# Environment Variable

pip install python-dotenv

From dotenv import load_dotenv
load_dotenv()
import os
token = os.environ.get("api-token")
1
2
3
4
api-token = "abcdef_123456"
1
Last Updated: 3/1/2021, 9:19:08 PM