-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselenium_driver1.py
More file actions
74 lines (54 loc) · 1.69 KB
/
Copy pathselenium_driver1.py
File metadata and controls
74 lines (54 loc) · 1.69 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from selenium import webdriver
import time
import requests
#from selenium.webdriver.common.virtual_authenticator import VirtualAuthenticatorOptions
#cookies_dict = {}
#used this link for testing cookies retrieval and other selenium functions
#chose this url because it is my alma mater site and I am familiar with it, however i was blocked by the fire wall eventually
url = "https://www.starbucks.com/"
timer = 2
#url = "http://localhost:8080"
driver = webdriver.Safari('./safaridriver')
print("still alive")
#driver = webdriver.Firefox()
#x = driver.get(url)
#y = driver.get_network_conditions()
#print(y)
#print(x)
#help(driver)
#print(driver.get.__doc__)
driver.get(url)
driver.set_window_size(800, 600)
#driver.maximize_window()
time.sleep(timer)
#help(driver.get_cookies())
#response = requests.get(url, cookies=cookies_dict)
cookies_dict = {cookie['name']: cookie['value'] for cookie in driver.get_cookies()}
print("Cookies Dict:", cookies_dict)
print("Cookies:", driver.get_cookies())
with open('cookies.txt', 'a') as f:
for cookie in driver.get_cookies():
f.write(f"{cookie}\n")
#capturing only specific cookie
with open('specific_cookie.txt', 'a') as f:
session_data = driver.session_id
f.write(f"{session_data}\n")
x = 1
for i, k in cookies_dict.items():
f.write(f"{x} - {i}: {k}\n")
x += 1
# Testing page refresh
driver.refresh()
# Taking a screenshot
driver.save_screenshot('homepage.png')
#options VirtualAuthenticatorOptions(protocol="u2f", transport="usb")
#driver.add_virtual_authenticator(options)
print(driver.session_id)
time.sleep(timer)
driver.quit()
'''
print("testing")
time.sleep(10)
driver.quit()
#sleep(10)
'''