-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathM_ddt.py
33 lines (28 loc) · 924 Bytes
/
M_ddt.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
import csv, unittest
from selenium import webdriver
from ddt import ddt, data, unpack
def get_data(f_name):
data=[]
cont = csv.reader(open(f_name, "rb"))
next(cont, None)
for i in cont:
data.append(i)
return data
@ddt
class search (unittest.TestCase):
def setUp(self):
self.a = webdriver.Firefox()
self.a.implicitly_wait(30)
self.a.get("http://magento-demo.lexiconn.com/")
self.a.maximize_window()
@data (*get_data("testdata.csv"))
@unpack
def test_search(self,i,j):
self.a.find_element_by_xpath("//input[@id='search']").send_keys(i)
self.a.find_element_by_xpath("//input[@id='search']").submit()
lis1 = self.a.find_elements_by_xpath("//h2[@class='product-name']/a")
self.assertEqual(int(j), len(lis1))
def tearDown(self):
self.a.quit()
if __name__ == '__main__':
unittest.main(verbosity=2)