forked from VenkateshDoijode/selenium_with_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHtmlTestRunnerExample.py
More file actions
57 lines (44 loc) · 1.86 KB
/
Copy pathHtmlTestRunnerExample.py
File metadata and controls
57 lines (44 loc) · 1.86 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'''
Created on 04-Jul-2020
@author: venkateshwara D
'''
# pip install html-testRunner
# pip install selenium
# pip install webdrivermanager
from selenium import webdriver
import unittest
import time
import HtmlTestRunner
from webdriver_manager.chrome import ChromeDriverManager
class GoogleSearch(unittest.TestCase):
@classmethod
def setUpClass(cls):
#super(GoogleSearch, cls).setUpClass()
#cls.driver = webdriver.Chrome(executable_path='../Drivers/chromedriver.exe')
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'`
driver = webdriver.Chrome(executable_path=os.path.abspath(“chromedriver"), chrome_options=chrome_options)
driver.get("http://www.duo.com")`
cls.driver = webdriver.Chrome(ChromeDriverManager().install())
cls.driver.implicitly_wait(10)
cls.driver.maximize_window()
def test_searchForAutomation(self):
self.driver.get("http://google.com")
self.driver.find_element_by_name("q").send_keys("Automation")
time.sleep(1)
self.driver.find_element_by_name("btnK").click()
def test_searchForPython(self):
self.driver.get("http://google.com")
self.driver.find_element_by_name("q").send_keys("Python")
time.sleep(1)
self.driver.find_element_by_name("btnK").click()
@classmethod
def tearDownClass(cls):
#super(GoogleSearch, cls).tearDownClass()
cls.driver.close()
cls.driver.quit()
print ("Test Completed")
if __name__ == '__main__':
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='../Report'))