-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy path124 screenshots-generic.py
44 lines (37 loc) · 1.33 KB
/
124 screenshots-generic.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
34
35
36
37
38
39
40
41
42
43
44
'''
Created on May 30, 2018
@author: venkateshwara.d
'''
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import os
class Screenshots():
def test(self):
baseUrl = "https://letskodeit.teachable.com/"
chrome_driver_path = os.path.abspath('..') + "\\Drivers\\chromedriver.exe"
driver=webdriver.Chrome(chrome_driver_path)
driver.maximize_window()
driver.get(baseUrl)
driver.implicitly_wait(3)
driver.find_element(By.LINK_TEXT, "Login").click()
driver.find_element(By.ID, "user_email").send_keys("abc@email.com")
driver.find_element(By.ID, "user_password").send_keys("abc")
driver.find_element(By.NAME, "commit").click()
self.takeScreenshot(driver)
def takeScreenshot(self, driver):
"""
Takes screenshot of the current open web page
:param driver
:return:
"""
fileName = str(round(time.time() * 1000)) + ".png"
screenshotDirectory = "/Users/atomar/desktop/"
destinationFile = screenshotDirectory + fileName
try:
driver.save_screenshot(destinationFile)
print("Screenshot saved to directory --> :: " + destinationFile)
except NotADirectoryError:
print("Not a directory issue")
ff = Screenshots()
ff.test()