기타/기타

셀레니움 예시

fullfish 2023. 5. 11. 15:44
#Ch_selenium/example/tutorial1.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)

driver = webdriver.Chrome('./chromedriver',options=chrome_options) #또는 chromedriver.exe
driver.implicitly_wait(15) # 묵시적 대기, 활성화를 최대 15초가지 기다린다.

# 페이지 가져오기(이동)
driver.get('https://sfms.guro.go.kr/facility/group-maintenance')

loginBtn = driver.find_element(By.CSS_SELECTOR,'#slide-1 > div > button:nth-child(2)')
loginBtn.click()
id = driver.find_element(By.CSS_SELECTOR,'#__layout > main > div.g-height-100vh > div.simplebar-wrapper > div.simplebar-mask > div > div > div > section > div.ui.dimmer.modals.page.transition.visible.active > div > div > div.mx-auto.g-width-720 > div.w-100.g-mt-100.username.ui.left.icon.big.input > input[type=text]')
id.send_keys('id')
password = driver.find_element(By.CSS_SELECTOR,'#__layout > main > div.g-height-100vh > div.simplebar-wrapper > div.simplebar-mask > div > div > div > section > div.ui.dimmer.modals.page.transition.visible.active > div > div > div.mx-auto.g-width-720 > div.w-100.g-mt-20.passwd.ui.left.icon.big.input > input[type=password]')
password.send_keys('password!')
password.send_keys(Keys.ENTER)

print(loginBtn)

 

24.1.16

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
import time
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
service = Service('./chromedriver')
driver = webdriver.Chrome(service=service, options=chrome_options)


driver.implicitly_wait(15) # 묵시적 대기, 활성화를 최대 15초가지 기다린다.
driver.get('www.naver.com')



loginBtn = driver.find_element(By.XPATH,'/html/body/div[1]/div[5]/section/div[1]/div[1]/div[3]/div[6]/div/a')
loginBtn.click()

'기타 > 기타' 카테고리의 다른 글

supabase  (0) 2023.08.03
탭 선택 css  (0) 2023.06.21
사용중인 포트 죽이기  (1) 2023.05.02
코딩지도사 1급  (0) 2023.01.03
우분투 키보드 한영 설정  (0) 2022.11.02