-
Notifications
You must be signed in to change notification settings - Fork 6
/
test_chrome.py
41 lines (31 loc) · 1.04 KB
/
test_chrome.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import unittest
import time
from selenium import webdriver
class ChromeTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
# get the path of ChromeDriver
dir = os.getenv('ChromeWebDriver')
driver = os.path.join(dir, 'chromedriver.exe')
cls.browser = webdriver.Chrome(executable_path=driver)
@classmethod
def tearDownClass(cls):
cls.browser.quit()
def testGoogle(self):
self.browser.get('http://www.google.com')
self.assertIn('Google', self.browser.title)
time.sleep(2)
def testBing(self):
self.browser.get('http://www.bing.com')
self.assertIn('Bing', self.browser.title)
time.sleep(2)
def testYahoo(self):
self.browser.get('http://www.yahoo.com')
self.assertIn('Yahoo', self.browser.title)
def testOutlook(self):
self.browser.get('http://www.outlook.com')
self.assertIn('Outlook', self.browser.title)
time.sleep(2)
if __name__ == '__main__':
unittest.main(verbosity=2)