Browsertests with selenium
authorPeter Koppatz <peter@koppatz.com>
Tue, 21 Jan 2014 05:37:15 +0100
changeset 194ead607927876
parent 193 adefe033cca4
child 195 77dac27bbbbd
Browsertests with selenium
_tests/test_http_status.py
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/_tests/test_http_status.py	Tue Jan 21 05:37:15 2014 +0100
     1.3 @@ -0,0 +1,28 @@
     1.4 +from selenium import webdriver
     1.5 +from selenium.common.exceptions import NoSuchElementException
     1.6 +import time
     1.7 +import unittest
     1.8 +
     1.9 +from sayings import get_saying
    1.10 +
    1.11 +class HTTPStatusTest(unittest.TestCase):
    1.12 +    def checkURL(self, url):
    1.13 +        self.browser.get(url)
    1.14 +        try:
    1.15 +            h1 = self.browser.find_element_by_xpath("//h1")
    1.16 +            self.assertNotEqual(h1.text, "Page Not Found")
    1.17 +        except NoSuchElementException:
    1.18 +            pass
    1.19 +
    1.20 +
    1.21 +    def runTest(self):
    1.22 +        self.browser = webdriver.Firefox()
    1.23 +        path = "http://127.0.0.1:5014/"
    1.24 +        urls = ["", "index", "competition", "task", "submission", "coursematerial",
    1.25 +                "imprint", "privacy"]
    1.26 +        for url in urls:
    1.27 +            self.checkURL(path + url)
    1.28 +
    1.29 +
    1.30 +if __name__ == "__main__":
    1.31 +    unittest.main()
Impressum Datenschutzerklärung