리셋 되지 말자

docker django selenium 테스트 본문

TDD

docker django selenium 테스트

kyeongjun-dev 2021. 6. 18. 18:24

https://github.com/marcgibbons/django-selenium-docker/blob/master/app/tests.py

 

marcgibbons/django-selenium-docker

Example of Django Selenium testing w/ Docker. Contribute to marcgibbons/django-selenium-docker development by creating an account on GitHub.

github.com

 

https://medium.com/@adamking0126/a-simple-recipe-for-django-development-in-docker-bonus-testing-with-selenium-6a038ec19ba5

 

A Simple Recipe for Django Development In Docker (Bonus: Testing with Selenium)

Docker brings a host of advantages to software development, but I like it for two reasons: it decouples your code from the host operating…

medium.com

 

- tests.py

import socket
from urllib.parse import urlparse

from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.test import TestCase, override_settings, tag

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# Create your tests here.
class BaseTestCase(TestCase):
    """
    Provides base test class which connects to the Docker
    container running selenium.
    """
    def setUp(self):
        self.host = socket.gethostbyname(socket.gethostname())
        print(self.host)
        self.selenium = webdriver.Remote(
            command_executor='http://172.17.0.2:4444/wd/hub',
            desired_capabilities=DesiredCapabilities.CHROME,
        )
        self.selenium.implicitly_wait(5)

    def tearDown(self):
        self.selenium.quit()
    
    def test1(self):
        self.selenium.get('http://172.17.0.2:4444/wd/hub')
        print(self.selenium.current_url)
        print(self.selenium.title)
        print()
        self.selenium.get('http://192.168.0.53:8000')
        print(self.selenium.current_url)
        print(self.selenium.title)
        print(self.selenium.page_source)
        self.assertEqual(1+1 , 2, msg='Equal')

 

어... 어떻게 하는거지...?

'TDD' 카테고리의 다른 글

docker django selenium 테스트 - 2  (1) 2021.07.21
[Selenium] webdriver.dispose() .close() .quit() 차이  (0) 2021.06.22
[TDD with selenium] Django Selenium test 학습  (0) 2021.06.16
TDD 테스트 종류  (0) 2021.05.17
[TDD with Python] - 2  (0) 2021.05.17
Comments