Skip to content

Commit 4761eaf

Browse files
author
Gaurav Singh
committed
Chapter 4 + 5: Initializing eyes in your tests and running your first hello world test.
1 parent 9c65af8 commit 4761eaf

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

automation/tests/base_test.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
from unittest import TestCase
22

3+
from applitools.common import MatchLevel
4+
from applitools.selenium import Eyes
35
from selenium import webdriver
46

7+
from automation.config.base import APPLITOOLS_API_KEY
8+
59

610
class BaseTest(TestCase):
7-
def setUp(self):
11+
def setup(self, test_name):
812
self.driver = webdriver.Chrome()
913
self.driver.get('https://applitools.com/helloworld')
14+
self.eyes = self.open_eyes(test_name)
1015

11-
def tearDown(self):
16+
def teardown(self):
1217
self.driver.quit()
18+
self.close_eyes()
19+
20+
def open_eyes(self, test_name):
21+
self.eyes = Eyes()
22+
self.eyes.api_key = APPLITOOLS_API_KEY
23+
24+
self.eyes.match_level = MatchLevel.STRICT
25+
self.eyes.open(self.driver, app_name='hello_world',
26+
test_name=test_name)
27+
28+
return self.eyes
29+
30+
def close_eyes(self):
31+
self.eyes.close()
32+
33+
def validate_window(self, tag):
34+
self.eyes.check_window(tag)

automation/tests/chapter_04/hello_world.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44
class HelloWorldTest(BaseTest):
55

66
def test_hello_world(self):
7-
pass
7+
self.setup(test_name=self._testMethodName)
8+
9+
self.validate_window(tag='hello_world')
10+
self.driver.find_element_by_css_selector('button').click()
11+
self.validate_window('click_me')
12+
13+
self.teardown()

0 commit comments

Comments
 (0)