-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgvoice-ff.py
98 lines (83 loc) · 2.89 KB
/
gvoice-ff.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import time
import re
import sys
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException
options = Options()
options.add_argument("-headless")
driver = webdriver.Firefox(options=options, executable_path=r'C:\hpk\cd\geckodriver.exe')
driver.set_window_size(1024, 768)
driver.implicitly_wait(1)
driver.get('https://accounts.google.com/ServiceLogin?continue=https://www.google.com/voice&rip=1&nojavascript=1&followup=https://www.google.com/voice')
input_0 = False
for _ in range(30):
time.sleep(0.5)
try:
driver.find_element('id', 'il1')
break
except:
pass
doc=driver.page_source.encode('ascii', 'replace').decode('ascii')
p = re.search('Sign in to continue to Google Voice|Sign in with your Google Account', doc)
if p:
driver.find_element('name', 'Email').send_keys(sys.argv[1])
driver.find_element('id', 'next').click()
time.sleep(1)
# element = driver.find_element('xpath', "//*[contains(text(), 'Enter your password')]")
try:
element = driver.find_element_by_xpath('//input[@aria-label="Enter your password"]')
except:
doc=driver.page_source.encode('ascii', 'replace').decode('ascii')
print(doc)
actions = ActionChains(driver)
actions.move_to_element_with_offset(element, 1, 1)
actions.send_keys(sys.argv[2])
actions.send_keys(Keys.ENTER)
actions.perform()
time.sleep(2)
doc = driver.page_source.encode('ascii', 'replace').decode('ascii')
p = re.search('Make a call.*? class="([^ ]*)', doc)
if p:
print("MAKE A CALL", p.group(1))
time.sleep(1)
element = driver.find_element("class_name", p.group(1))
driver.execute_script("arguments[0].click();", element)
break
p = re.search('id="input_0"', doc)
if p:
print("INPUT_0")
input_0 = True;
break
driver.implicitly_wait(10)
try:
driver.find_element('id', 'il1').send_keys(sys.argv[3])
except:
print("GATE1")
print(driver.page_source.encode('ascii', 'replace').decode('ascii'))
driver.close()
driver.quit()
sys.exit()
driver.implicitly_wait(10)
driver.find_element('xpath','//*[@gv-test-id="new-call-button"]').click()
element = driver.find_element('xpath', '//*[@role="listbox"]')
driver.execute_script("arguments[0].click();", element)
element = driver.find_element('xpath', '//*[@role="option"]')
driver.execute_script("arguments[0].click();", element)
actions = ActionChains(driver)
actions.move_to_element_with_offset(element, 6, 6)
actions.click()
actions.perform()
element = driver.find_element('xpath', "//*[contains(text(), 'Connect')]")
driver.execute_script("arguments[0].click();", element)
time.sleep(0.3)
try:
element = driver.find_element('xpath', '//button[normalize-space()="Connect"]')
driver.execute_script("arguments[0].click();", element)
except:
pass
time.sleep(5)
driver.close()
driver.quit()