Python Unittest - XXOK/XXOK-selenium GitHub Wiki
Python Unittest
webdriver import
from selenium import webdriver
ν
μ€νΈ μΌμ΄μ€κ° μμ±λ class μ μ
- ν
μ€νΈλ₯Ό μ€ννκΈ° μν ν΄λμ€λ unittest ν¨ν€μ§μ TestCase ν΄λμ€λ₯Ό μμλ°λλ€.
import unittest
class mainTest(unittest.TestCase):
runTest(self), setUp(self), tearDown(self) μ΄λ κ² μΈ κ°μ λ©μλλ₯Ό μ€λ²λΌμ΄λνλ€.
from selenium import webdriver
import unittest
class mainTest(unittest.TestCase):
def setUp(self):
# ν
μ€νΈ νκΈ° μ μ νμν μ€μ μΌλ‘ μ¬λ¬ ν
μ€νΈ μΌμ΄μ€κ° 곡μ νλ μ€μ μ μν΄ μ¬μ©λλ©°, μ¬λ¬ ν
μ€νΈ μΌμ΄μ€κ° μμνλ λ² μ΄μ€ ν΄λμ€μ μ μλλ€.
def runTest(self):
# assertion, exception λ±μ΄ λ°μνλ©΄ ν
μ€νΈ μ€ν¨ return.
def tearDown(self):
# setUpμ΄ μ±κ³΅νλ€λ©΄, runTest κ²°κ³Όμ μκ΄μμ΄ tearDownμ΄ μ€νλλ€.
driver λΌλ μ΄λ¦μ webdriver κ°μ²΄ μμ±
def setUp(self):
self.chromeDriver = PATH('../drivers/mac/chromedriver') # chromedriver μμΉ κ²½λ‘
self.driver = webdriver.Chrome(executable_path=self.chromeDriver)
Reference
http://springs-thursday.iptime.org/?p=130