[Daily Contents] 셀레니움 활용하기


셀레니움이란?

셀레늄(소프트웨어)

  • 셀레늄은 웹 애플리케이션 테스트를 위한 포터블 프레임워크이다. 셀레늄은 테스트 스크립트 언어를 학습할 필요 없이 기능 테스트를 만들기 위한 플레이백 도구를 제공한다.
  • 웹에서 크롤링할 때 사용, 오픈 소스.
WebDriver, Language, bindings
Java, C#, Python, Ruby, R, JavaScript

->

JSON Wire Protocol

->

Browser Drivers
ChromeDriver, IEDriver, GeckoDriver, SafariDriver, HTMLDriver…

<=> HTTP over HTTP Server

Browsers
Chrome, IE, Safari…

셀레니움 용도?

  • 음식점 목록, 영화관 목록, 관광지 목록 등
  • 이미지 자동 다운로드 등
  • 기타 우리 프로젝트에 필요한 정보
  • 자동 소송 프로그램

개발 설정

self.driver = webdriver.Chrome(ChromeDriverManager().install())
PATH = 'G:\python\selenium\chromedriver.exe'
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_experimental_option('excludeSwitches', ['enable-logging])

개발

ele = self.driver.find_element_by_id('userId1')
check = ele.is_displayed()
if check :
	ele.clear()
    ele.click()
    sleep(1)
    for s in site_id:
    	if s == '2':
        	ele.send_keys(Kets.NUMPAD2)
        # elif s == '6':
        #	ele.send_keys(Keys.NUMPAD6)
        else:
        	ele.send_keys(s)
  • 숫자 2가 입력이 안 되는 현상에 NUMPAD로 입력
self.driver.find_element_by_id('btnLgn').click()
sleep(1)
elements = self.driver.find_elements_by_xpath('//*[@id="xwup_cert_table"]/table/tbody/tr)
elements[cert_index].click()
sleep(1)
actions = ActionsChains(self.driver)
## 원고 입력
actions.move_to_element(hover).perform()
self.driver.find_element_by_xpath('//*[@id="tmenu01"]/div/ul/li[2]a').click()
self.driver.find_element_by_xpath('//*[@id="tabDoc"]/div[1]/ul/li[1]/a/img').click()
self.driver.find_element_by_xpath('//*[@id="chkArgElcSo"]').click()
self.driver.find_element_by_xpath('//*[@id="btnDsSo"]).click()
## 법원선택
x = self.driver.find_element_by_xpath('//*[@id="cmbBubCd"]')
drop=Select(x)
drop.select_by_visible_text(target_agency)
## 피해금액
self.driver.switch_to_alert().accept()
self.driver.find_element_by_xpath('//*[@id="soSogaAmt"]').send_keys(money)

innorixst

  • 보안으로 인하여 셀레니움으로 자료를 긁을 수 없을 경우

업그레이드 QML(디자인)

from PyQt5.QtCore import Qobject, pyqtSlot, pyqtSignal

class HomeFunctions(QObject):
	signal = pyqtSignal()
    def __init__(self):
    QObject.__init__(self)

    @pyqtSlot()
    def changePage(self):
    	print("Button was pressed")
    @pyqtSlot()
    def cert(self, str):
    	print("cert started", str)

정리

수기로 적는 문서의 프로그램 자동화는 나름 블루오션.
단 위와 같은 법조계에 도움을 주는 자동화 시스템의 경우, 전국의 변호사가 10만명도 채 되지 않는다는 고객층 숫자 이슈가 있어 사업을 하고자 한다면 사전 조사 필수
IT계에서 직접 해 보는 것보다 이론적으로 행해지는 것이 많음
예를 들어 FE를 개발해 본 적이 없는 이들이 Vue가 우수한가 React가 우수한가로 논쟁을 펼치곤 함.
IT에 종사하시는 분들은 이론으로 대결하지 말고 사람들에게 이로운 서비스를 제공하는 방향으로 개발하는 것이 올바른 방향이 아닐까.

댓글남기기