1+ #error in creating html reports
2+ import time
3+ import unittest
4+ from HtmlTestRunner import HTMLTestRunner
5+ from selenium import webdriver
6+ from Seleniumpython .PomProjectDemo .Pages .loginPage import LoginPage
7+ from Seleniumpython .PomProjectDemo .Pages .homepage import HomePage
8+
9+ class LoginTest (unittest .TestCase ):
10+
11+ @classmethod
12+ def setUpClass (cls ):
13+ cls .driver = webdriver .Chrome (executable_path = "C:\driver\chromedriver.exe" )
14+ cls .driver .maximize_window ()
15+
16+ def test_login_valid (self ):
17+ driver = self .driver # created to avoid self.driver everywhere
18+ driver .get ("https://opensource-demo.orangehrmlive.com/index.php/dashboard" )
19+
20+ login = LoginPage (driver )
21+ login .enter_username ("Admin" )
22+ login .enter_password ("admin123" )
23+ login .click_login ()
24+
25+ homepage = HomePage (driver )
26+ homepage .click_welcome ()
27+ homepage .click_logout ()
28+
29+ time .sleep (2 )
30+
31+
32+ @classmethod
33+ def tearDownClass (cls ):
34+ cls .driver .close ()
35+ print ("Test Completed" )
36+
37+ if __name__ == '__main__' :
38+ unittest .main (testRunner = HTMLTestRunner (output = 'E:/Programming/Seleniumpython/PomProjectDemo/Reports' ))
39+
40+ # Pom ,unit test and html reports
41+ # installed html-test runner and selenium from cmd
42+ # 1.create a simple login test
43+ # 2.implement unit testing
44+ # 3.implement page object model
45+ # 4.seperate test script and objects
46+ # 5.create a separate class for locators
47+ # 6.run from cmd
48+ # 7.add html reports
49+
50+ # note: classmethod is used due to using setupclass and teardownclass methods
51+ # run-edit configuration-add pythontest from + sign-delete login in python-pythontest-unittest-name(login)-location.
52+
53+ # print(self.driver.title)
54+ # self.driver.implicitly_wait(2)
55+ # self.driver.find_element_by_id("txtUsername").send_keys("Admin")
56+ # self.driver.find_element_by_id("txtPassword").send_keys("admin123")
57+ # self.driver.find_element_by_id("btnLogin").click()
58+ # time.sleep(4)
59+ # self.driver.find_element_by_id("welcome").click()
60+ # self.driver.find_element_by_link_text("Logout").click()
61+ # time.sleep(4)
0 commit comments