assertEqual/assertTrue 등 testcode를 통한 오류유무를 확인해보는 간단한 예제
from selenium import webdriver
import unittest
class FunctionalTest(unittest.TestCase):
def setUp(self):
path = './chromedriver'
self.driver = webdriver.Chrome(path)
def tearDown(self):
self.driver.quit()
def test_go_to_question_detail_page(self):
self.driver.get("http://localhost:8000/polls/")
a_tag = self.driver.find_elements_by_tag_name("li > a")[1]
self.assertIn( "What's new?", a_tag.text)
a_tag.click()
self.assertEqual(self.driver.current_url, "http://localhost:8000/polls/1/")
self.assertIn(self.driver.find_element_by_tag_name("h1").text, "What's new?")
li_tags = self.driver.find_elements_by_tag_name("ul > li")
self.assertTrue(
any(li_tag.text == "choice!" for li_tag in li_tags)
)
self.assertTrue(
any(li_tag.text == "choice!" for li_tag in li_tags)
)
https://galid1.tistory.com/783
https://brunch.co.kr/@springboot/418#comment
https://idlecomputer.tistory.com/29
코드에 대한 이해가 우선이다. sugar syntax보다는 sugar logic!