Selenium Webdriver – Python with Unittest

By | 21/12/2014

in a previous post, i present a Python script to run some basic selenium functions.By the following example, you can run your Python code unittest format. it completely has same result with that one. but, unittest framework has some advantages to use. in next post, i will publish some example, specially Assert functions provide a powerful way to verify your checkpoints and reporting them.

When you run following code, your result will be “OK”

# -*- coding: UTF-8 -*-
import unittest
from selenium import webdriver

class TestClass(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(20)
        self.driver.set_page_load_timeout(20)
        self.driver.maximize_window()
    
    def test_Mahsum_Foo(self):
        self.driver.get("http://www.mahsumakbas.net")
        print self.driver.title
    
    def tearDown(self):
        self.driver.close()

if __name__ == '__main__':
    unittest.main()

Leave a Reply

Your email address will not be published. Required fields are marked *

*