File tree Expand file tree Collapse file tree 5 files changed +81
-9
lines changed Expand file tree Collapse file tree 5 files changed +81
-9
lines changed Original file line number Diff line number Diff line change 11from selenium import webdriver
2- from selenium .webdriver .chrome .webdriver import WebDriver
3- from selenium .webdriver .common .by import By
42from selenium .webdriver .remote import webelement
53from Library .store import Store
64
5+
76class Driver :
87 driver = None
98
10- def __init__ (self ,browser = "chrome" ) -> None :
9+ def __init__ (self , browser = "chrome" ) -> None :
1110 if browser == "chrome" :
12- self .driver = webdriver .Chrome ()
11+ options = webdriver .ChromeOptions ()
12+ options .add_argument ("--no-sandbox" )
13+ options .add_argument ("--foreground" )
14+ options .add_argument ('disable-infobars' )
15+ options .add_argument ("--disable-extensions" )
16+ # options.add_argument("--headless")
17+ self .driver = webdriver .Chrome (options = options )
18+ self .driver .implicitly_wait (20 )
1319 elif browser == "firefox" :
1420 self .driver = webdriver .Firefox ()
1521 elif browser == "safari" :
@@ -22,4 +28,7 @@ def get(self, url: str) -> None:
2228 def find_element (self , by , value ) -> webelement .WebElement :
2329 return self .driver .find_element (by , value )
2430
31+ def quit (self ):
32+ self .driver .quit ()
33+
2534
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+
4+ @pytest .fixture (autouse = True )
5+ def before_all ():
6+ print ('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ INITIALIZATION' )
7+ yield
8+ print ('######################################### END' )
9+
10+
11+ def pytest_configure (config ):
12+ """
13+ Allows plugins and conftest files to perform initial configuration.
14+ This hook is called for every plugin and initial conftest
15+ file after command line options have been parsed.
16+ """
17+ print ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ pytest_configure" )
18+
19+
20+ def pytest_sessionstart (session ):
21+ """
22+ Called after the Session object has been created and
23+ before performing collection and entering the run test loop.
24+ """
25+ print ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ pytest_sessionstart" )
26+
27+
28+ def pytest_sessionfinish (session , exitstatus ):
29+ """
30+ Called after whole test run finished, right before
31+ returning the exit status to the system.
32+ """
33+ print ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ pytest_sessionfinish" )
34+
35+
36+ def pytest_unconfigure (config ):
37+ """
38+ called before test process is exited.
39+ """
40+ print ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ pytest_unconfigure" )
Original file line number Diff line number Diff line change 11import pytest
2+ import allure
23from Library .driver import Driver
3- from Library .locator import Locator
44from Pages .google import GooglePage
55
66
7- def test_file1_method1 ():
8- d = Driver ("chrome" )
9- d .get ("https://www.google.com" )
10- GooglePage .enter_search_text ("hello" )
7+ @allure .feature ("Google Search" )
8+ @allure .step ('Enter and search' )
9+ @allure .severity ('Critical' )
10+ def test_google_search ():
11+ with allure .step ("first step" ):
12+ d = Driver ("chrome" )
13+ d .get ("https://www.google.com" )
14+ print ("landed in google home page" )
15+
16+ with allure .step ("second step" ):
17+ GooglePage .enter_search_text ("hello" )
18+ d .quit ()
19+
20+
21+ @allure .feature ("Google Search 2" )
22+ @allure .step ('Enter and search 2' )
23+ @allure .severity ('Critical' )
24+ def test_google_search2 ():
25+ with allure .step ("first step 2" ):
26+ d = Driver ("chrome" )
27+ d .get ("https://www.google.com" )
28+ print ("landed in google home page" )
29+
30+ with allure .step ("second step 2" ):
31+ GooglePage .enter_search_text ("hello" )
32+ d .quit ()
Original file line number Diff line number Diff line change @@ -11,3 +11,4 @@ addopts = -rsxX
1111 --html =html_report.html
1212 --cov =Tests
1313 --alluredir report
14+ --clean-alluredir
You can’t perform that action at this time.
0 commit comments