bcpkgfox 0.16.77__tar.gz → 0.17.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bcpkgfox might be problematic. Click here for more details.
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/PKG-INFO +1 -1
- bcpkgfox-0.17.1/bcpkgfox/examples copy.py +227 -0
- bcpkgfox-0.17.1/bcpkgfox/examples.py +153 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox/invoke_api.py +15 -14
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox.egg-info/PKG-INFO +1 -1
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox.egg-info/SOURCES.txt +2 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/setup.py +1 -1
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/README.md +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox/__init__.py +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox/clean.py +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox/cli.py +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox/find_elements.py +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox/get_driver.py +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox/system.py +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox.egg-info/dependency_links.txt +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox.egg-info/entry_points.txt +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox.egg-info/requires.txt +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/bcpkgfox.egg-info/top_level.txt +0 -0
- {bcpkgfox-0.16.77 → bcpkgfox-0.17.1}/setup.cfg +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
'''
|
|
2
|
+
A grande maioria das classes e funções tem descrição explicando com detalhes o funcionamento e parametros
|
|
3
|
+
Para ver clicar na classe/função e apertar ctrl+K ctrl+I (VSCODE)
|
|
4
|
+
'''
|
|
5
|
+
import neri_library as nr # Só precisa de um import para
|
|
6
|
+
from neri_library import DK_ORANGE, ORANGE, GR, RD, RESET # Colors for terminal
|
|
7
|
+
|
|
8
|
+
# Default
|
|
9
|
+
import time
|
|
10
|
+
import sys
|
|
11
|
+
import os
|
|
12
|
+
|
|
13
|
+
class Browser():
|
|
14
|
+
def __init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
self.arguments = None
|
|
18
|
+
self.instance = None
|
|
19
|
+
self.browser = None
|
|
20
|
+
self.el = None
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def __simple_example():
|
|
24
|
+
'''
|
|
25
|
+
Aqui é só um exemplo de como é fácil iniciar um navegador com a lib.
|
|
26
|
+
Ja vem com configurações para evitar detecção e passar por captchas.
|
|
27
|
+
'''
|
|
28
|
+
Browser = nr.Instancedriver().initialize_driver()
|
|
29
|
+
Browser.get('URL SITE')
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def browser_iniciate(self):
|
|
33
|
+
'''
|
|
34
|
+
Aqui é um exemplo de driver em produção.
|
|
35
|
+
'''
|
|
36
|
+
print(f'{ORANGE} [ Inicializando Browser ] {RESET}')
|
|
37
|
+
|
|
38
|
+
# Inicia a instância do Navegador
|
|
39
|
+
self.instance = nr.Instancedriver(
|
|
40
|
+
Browser= 'Chrome',
|
|
41
|
+
# Browser="Firefox",
|
|
42
|
+
# Browser="edge",
|
|
43
|
+
# Browser="internet explorer",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Inicia a instancia dos argumentos (opcional, não precisa por nenhum)
|
|
47
|
+
self.arguments = self.instance.arguments # Instância dos argumentos
|
|
48
|
+
|
|
49
|
+
# Fix: Abaixo alguns dos principais exemplos de argumento do selenium (tem todos)
|
|
50
|
+
# Exemplos de args para desligar indicadores de automação
|
|
51
|
+
self.arguments.add_experimental_option("excludeSwitches", ["enable-automation"])
|
|
52
|
+
self.arguments.add_experimental_option("useAutomationExtension", False)
|
|
53
|
+
self.arguments.add_argument("--disable-blink-features=AutomationControlled")
|
|
54
|
+
self.arguments.add_argument("--disable-blink-features")
|
|
55
|
+
self.arguments.add_argument("--disable-infobars")
|
|
56
|
+
self.arguments.add_argument("--disable-blink-features=AutomationControlled")
|
|
57
|
+
self.arguments.add_argument("--blink-settings=imagesEnabled=false")
|
|
58
|
+
|
|
59
|
+
# Exemplos de args para evitar detecção da automação nos sites e captchas
|
|
60
|
+
# Fix: Mas ja vem por padrão diversos argumentos tratando isso na função de 'initialize_driver'
|
|
61
|
+
self.arguments.add_argument("--disable-background-networking")
|
|
62
|
+
self.arguments.add_argument("--disable-sync")
|
|
63
|
+
self.arguments.add_argument("--disable-client-side-phishing-detection")
|
|
64
|
+
self.arguments.add_argument("--disable-popup-blocking")
|
|
65
|
+
self.arguments.add_argument("--disable-default-apps")
|
|
66
|
+
self.arguments.add_argument("--disable-features=IsolateOrigins,site-per-process")
|
|
67
|
+
self.arguments.add_argument("--disable-features=BlockInsecurePrivateNetworkRequests")
|
|
68
|
+
self.arguments.add_argument("--ignore-certificate-errors")
|
|
69
|
+
self.arguments.add_argument("--disable-gpu")
|
|
70
|
+
|
|
71
|
+
# Abaixo alguns exemplos para remover os logs do terminal (deixar mais limpo)
|
|
72
|
+
self.arguments.add_argument("--log-level=3")
|
|
73
|
+
self.arguments.add_experimental_option("excludeSwitches", ["enable-logging"])
|
|
74
|
+
self.arguments.add_experimental_option("useAutomationExtension", False)
|
|
75
|
+
|
|
76
|
+
# Exemplo de adicionar extensão (pega automático tanto pasta como .crx)
|
|
77
|
+
# self.instance.add_extensions('your_extension')
|
|
78
|
+
|
|
79
|
+
# Inicia o browser (driver)
|
|
80
|
+
self.browser = self.instance.initialize_driver(maximize=True)
|
|
81
|
+
|
|
82
|
+
# Instancia o 'finder', contém todas as funções de busca envolvendo o navegador
|
|
83
|
+
self.finder = self.instance.elements
|
|
84
|
+
|
|
85
|
+
class RPA_example(Browser):
|
|
86
|
+
def __init__(self):
|
|
87
|
+
super().__init__()
|
|
88
|
+
|
|
89
|
+
def open_site(self):
|
|
90
|
+
self.driver.get('https://github.com/NeriAzv')
|
|
91
|
+
|
|
92
|
+
self.cidade = cidade
|
|
93
|
+
self.pop_up_protection.start()
|
|
94
|
+
|
|
95
|
+
# Pesquisa
|
|
96
|
+
pesquisa = self.find_element_w(By.ID, 'searchGeneral')
|
|
97
|
+
time.sleep(1)
|
|
98
|
+
pesquisa.send_keys(cidade)
|
|
99
|
+
|
|
100
|
+
# Espera carregamento pesquisa
|
|
101
|
+
tempo = 0
|
|
102
|
+
while tempo < 30:
|
|
103
|
+
resultados = self.find_elements_w(By.XPATH, '//ul[@id="autocompleteSuggestions"]//li')
|
|
104
|
+
|
|
105
|
+
if resultados:
|
|
106
|
+
break
|
|
107
|
+
else:
|
|
108
|
+
time.sleep(1)
|
|
109
|
+
tempo += 1
|
|
110
|
+
|
|
111
|
+
# Resutaldos pesquisa
|
|
112
|
+
elemento_resultados_pesquisa = self.find_element_w(By.ID, 'autocompleteSuggestions')
|
|
113
|
+
soup = BeautifulSoup(elemento_resultados_pesquisa.get_attribute('outerHTML'), 'html.parser')
|
|
114
|
+
ul = soup.find('ul', id='autocompleteSuggestions')
|
|
115
|
+
|
|
116
|
+
cidades_extraidas = []
|
|
117
|
+
extrair = False
|
|
118
|
+
for tag in ul.find_all(recursive=False):
|
|
119
|
+
if tag.name == 'h6':
|
|
120
|
+
if 'Cidades' in tag.text:
|
|
121
|
+
extrair = True
|
|
122
|
+
continue
|
|
123
|
+
elif extrair:
|
|
124
|
+
break
|
|
125
|
+
|
|
126
|
+
if extrair and tag.name == 'li':
|
|
127
|
+
cidades_extraidas.append(tag)
|
|
128
|
+
|
|
129
|
+
if not cidades_extraidas:
|
|
130
|
+
raise Exception(f"{RED} > Cidade {cidade} não presente no site, verifique o nome. {RESET}")
|
|
131
|
+
|
|
132
|
+
# Eu poderia ter clicado no ultimo for, mas estou fazendo separado pegar todas as cidades e fazer um LOG mais organizado
|
|
133
|
+
for cidade_site in cidades_extraidas:
|
|
134
|
+
cidade_site_formatado = self.remover_acentos(cidade_site.text).lower()
|
|
135
|
+
cidade_user_formatado = self.remover_acentos(cidade).lower()
|
|
136
|
+
|
|
137
|
+
# Retorna em porcentagem quanto similar está com o nome do site (evita erros de usuários)
|
|
138
|
+
if cidade_site_formatado in cidade_site_formatado:
|
|
139
|
+
|
|
140
|
+
self.find_element_w(
|
|
141
|
+
By.XPATH,
|
|
142
|
+
f'//ul[@id="autocompleteSuggestions"]//li[normalize-space()="{cidade_site.text.strip()}"]'
|
|
143
|
+
).click()
|
|
144
|
+
|
|
145
|
+
return
|
|
146
|
+
|
|
147
|
+
raise Exception(f"{RED} > Cidade {cidade} não presente no site, verifique o nome. {RESET}")
|
|
148
|
+
|
|
149
|
+
def extrair_previsao(self) -> dict:
|
|
150
|
+
|
|
151
|
+
espera_site = 0
|
|
152
|
+
while espera_site <= 5:
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
soup = BeautifulSoup(self.driver.page_source, "html.parser")
|
|
156
|
+
ul = soup.find("ul", class_="variables-list")
|
|
157
|
+
resultado_json = {
|
|
158
|
+
"cidade": self.cidade,
|
|
159
|
+
"temperatura_min": None,
|
|
160
|
+
"temperatura_max": None,
|
|
161
|
+
"condicao": None,
|
|
162
|
+
"umidade_min": None,
|
|
163
|
+
"umidade_max": None,
|
|
164
|
+
"vento": None,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if not ul:
|
|
168
|
+
return resultado_json
|
|
169
|
+
|
|
170
|
+
for li in ul.find_all("li", class_="item"):
|
|
171
|
+
label = li.find("span", class_="variable").get_text(strip=True)
|
|
172
|
+
|
|
173
|
+
if label == "Temperatura":
|
|
174
|
+
spans = li.select("span.-gray-light")
|
|
175
|
+
min_txt = spans[0].get_text(strip=True)
|
|
176
|
+
max_txt = spans[1].get_text(strip=True)
|
|
177
|
+
resultado_json["temperatura_min"] = min_txt if min_txt.endswith("°") else min_txt + "°"
|
|
178
|
+
resultado_json["temperatura_max"] = max_txt if max_txt.endswith("°") else max_txt + "°"
|
|
179
|
+
|
|
180
|
+
elif label == "Umidade":
|
|
181
|
+
spans = li.select("span.-gray-light")
|
|
182
|
+
resultado_json["umidade_min"] = spans[0].get_text(strip=True)
|
|
183
|
+
resultado_json["umidade_max"] = spans[1].get_text(strip=True)
|
|
184
|
+
|
|
185
|
+
elif label == "Vento":
|
|
186
|
+
texto = li.find("div", class_="_flex").get_text(separator=" ", strip=True)
|
|
187
|
+
texto_limpo = " ".join(texto.split())
|
|
188
|
+
resultado_json["vento"] = texto_limpo.replace("Vento", "", 1).strip()
|
|
189
|
+
|
|
190
|
+
elif label == "Sol":
|
|
191
|
+
nasc, _, pst = li.find("span", recursive=False).get_text(strip=True).partition(" ")
|
|
192
|
+
resultado_json["condicao"] = f"{nasc} {pst}"
|
|
193
|
+
|
|
194
|
+
return resultado_json
|
|
195
|
+
|
|
196
|
+
except:
|
|
197
|
+
time.sleep(1)
|
|
198
|
+
espera_site +=1
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class Logs:
|
|
203
|
+
''' Server somente para impressão de resultados, não afeta o funcionamento do robo '''
|
|
204
|
+
def imprimir_logs(self, log_resultado: dict):
|
|
205
|
+
if not log_resultado:
|
|
206
|
+
return
|
|
207
|
+
|
|
208
|
+
print(f"\n{BOLD}{BLUE} {log_resultado.get('cidade', '').title()}:{RESET}")
|
|
209
|
+
|
|
210
|
+
# Itera sobre o dict
|
|
211
|
+
for chave, valor in log_resultado.items():
|
|
212
|
+
if chave == "cidade":
|
|
213
|
+
continue
|
|
214
|
+
print(f" - {BLUE}{chave.capitalize()}:{RESET} {valor}")
|
|
215
|
+
|
|
216
|
+
def main():
|
|
217
|
+
|
|
218
|
+
# Instâncias
|
|
219
|
+
br = Browser()
|
|
220
|
+
rpa = RPA_example()
|
|
221
|
+
|
|
222
|
+
br.browser_iniciate()
|
|
223
|
+
rpa.open_site()
|
|
224
|
+
|
|
225
|
+
if __name__ == "__main__":
|
|
226
|
+
print(f'{DK_ORANGE} [ Robo Iniciado ] {RESET}')
|
|
227
|
+
main()
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
|
|
2
|
+
# FIX: Driver
|
|
3
|
+
# region Driver
|
|
4
|
+
"""
|
|
5
|
+
Example of how easy is start the driver.
|
|
6
|
+
|
|
7
|
+
It automatically configure the driver with stealth settings to pass over the captchas.
|
|
8
|
+
It also automatically prevents a various bugs like versions incompatibles and others.
|
|
9
|
+
"""
|
|
10
|
+
import neri_library as nr
|
|
11
|
+
|
|
12
|
+
# To choose the browser just change the name
|
|
13
|
+
driver = nr.Instancedriver(
|
|
14
|
+
Browser="chrome"
|
|
15
|
+
# Browser="Firefox"
|
|
16
|
+
# Browser="edge"
|
|
17
|
+
# Browser="internet explorer"
|
|
18
|
+
).initialize_driver()
|
|
19
|
+
|
|
20
|
+
driver.get("https://www.google.com")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# FIX: Driver Options
|
|
25
|
+
# region Driver Options
|
|
26
|
+
"""
|
|
27
|
+
You can also use arguments to configure the driver manually
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
import neri_library as nr
|
|
31
|
+
|
|
32
|
+
instance = nr.Instancedriver(Browser="chrome")
|
|
33
|
+
instance.initialize_options() # Iniciate the options mode
|
|
34
|
+
|
|
35
|
+
# Here you can add as many as you want
|
|
36
|
+
instance.arguments.add_new_argument("--headless") # Example
|
|
37
|
+
instance.arguments.add_experimental_option("useAutomationExtension", False) # Example
|
|
38
|
+
instance.arguments.add_experimental_options("excludeSwitches", ["enable-automation"]) # Example
|
|
39
|
+
|
|
40
|
+
# You can add a extension with one line too (already have 'resourse path')
|
|
41
|
+
instance.add_extension("path/to/extension.crx")
|
|
42
|
+
|
|
43
|
+
driver = instance.initialize_driver()
|
|
44
|
+
driver.get("https://www.google.com")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# FIX: Selenoid
|
|
49
|
+
# region Selenoid
|
|
50
|
+
"""
|
|
51
|
+
Functions of selenoid (docker)
|
|
52
|
+
|
|
53
|
+
The driver comes already configured to run in selenoid, but you can also configure it manually.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
import neri_library as nr
|
|
57
|
+
|
|
58
|
+
instance = nr.Instancedriver(Browser="chrome", Selenoid=True)
|
|
59
|
+
|
|
60
|
+
# Example if you wanna to customize
|
|
61
|
+
instance.Selenoid.add_capabilities("enableVNC", True) # Example
|
|
62
|
+
instance.Selenoid.add_capabilities("versiion", "122.0") # Example
|
|
63
|
+
|
|
64
|
+
driver = instance.initialize_driver()
|
|
65
|
+
driver.get("https://www.google.com")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# FIX: Elements
|
|
70
|
+
#region Elements
|
|
71
|
+
"""
|
|
72
|
+
Some features of selenium that i improve to prevents bugs and work correctly.
|
|
73
|
+
|
|
74
|
+
(you only need import the neri_library)
|
|
75
|
+
"""
|
|
76
|
+
import neri_library as nr
|
|
77
|
+
from neri_library import By # Optional to imitating selenium, you can use 'xpath' in place of By.XPATH for example
|
|
78
|
+
|
|
79
|
+
instance = nr.Instancedriver()
|
|
80
|
+
driver = instance.initialize_driver()
|
|
81
|
+
finder = instance.elements
|
|
82
|
+
|
|
83
|
+
# Selenium searchers
|
|
84
|
+
example = finder.find_element_with_wait(By.XPATH, '/your/xpath/here') # Have too XPATH, CSS, NAME, ID...
|
|
85
|
+
example_list = finder.find_elements_with_wait(By.XPATH, '/this/brings/a/list') # work same as the fn above (this have a 's' in the name)
|
|
86
|
+
|
|
87
|
+
# Selenium interactions works normally too
|
|
88
|
+
finder.find_element_with_wait(By.XPATH, '/elmt/xpath').send_keys('')
|
|
89
|
+
finder.find_element_with_wait(By.NAME, 'elmt_name').clear()
|
|
90
|
+
finder.find_element_with_wait(By.ID, 'elmt_id').click()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# FIX: Elemets created
|
|
95
|
+
#region Creations
|
|
96
|
+
"""
|
|
97
|
+
Below some functions that i created for web scraping
|
|
98
|
+
"""
|
|
99
|
+
import neri_library as nr
|
|
100
|
+
from neri_library import By
|
|
101
|
+
|
|
102
|
+
instance = nr.Instancedriver()
|
|
103
|
+
driver = instance.initialize_driver()
|
|
104
|
+
finder = instance.elements
|
|
105
|
+
|
|
106
|
+
# Just a example to uso on the functions below
|
|
107
|
+
example_element = finder.find_element_with_wait(By.XPATH, '/example')
|
|
108
|
+
|
|
109
|
+
'''
|
|
110
|
+
This function moves the mouse to an element imitating human behavior, to avoid captchas.
|
|
111
|
+
With some deviations and inaccuracies on the way to the destination (like a human).
|
|
112
|
+
( It use a external UI methods, so the browser can't detect )
|
|
113
|
+
'''
|
|
114
|
+
finder.move_mouse_smoothly(
|
|
115
|
+
element = example_element,
|
|
116
|
+
pure = True, # Pure is to you pass the cordinates instead the element
|
|
117
|
+
click = False,
|
|
118
|
+
x_adittional = 100, # Here you can add a number on cordinates (if the elements is bugged)
|
|
119
|
+
y_adittional = 100
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Find a image in the screen (you can pass a screenshot of a element)
|
|
123
|
+
finder.move_to_image(
|
|
124
|
+
'img_path.png', # You can send a list to search for more than one
|
|
125
|
+
click_on_final = True,
|
|
126
|
+
trail = True, # Move your mouse using 'move_mouse_smoothly' above (if False will teleport you mouse)
|
|
127
|
+
verify = True, # Just verify if the image is on the screen (Deactivates the 'trail' and 'click')
|
|
128
|
+
tolerancia = 0.8, # Deviation tolerance of the found image (0.8 = 80%)
|
|
129
|
+
timeout = 10, # The time that function will search the image(s)
|
|
130
|
+
repeat = True # It deactivates the 'timeout'
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# It will respect the timeout ignoring the "ClickInterrupted" errors
|
|
134
|
+
finder.wait_for_element_be_clickable(By.CLASS_NAME, 'elmt_class', timeout=10)
|
|
135
|
+
|
|
136
|
+
# It is a 'driver.execute_script' of the selenium, but with a timeout
|
|
137
|
+
finder.script_console_with_wait('Returns element.value', timeout = 10)
|
|
138
|
+
|
|
139
|
+
'''
|
|
140
|
+
You can use this function below to wait for a image, window, element or text.
|
|
141
|
+
'''
|
|
142
|
+
finder.wait_for_appear(
|
|
143
|
+
object = '', # title_window / img_path / text / element
|
|
144
|
+
type = '', # window / image / text / element (here you really write the type)
|
|
145
|
+
timeout = 10
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
finder.wait_for_appear( # finder.wait_for_appear( # finder.wait_for_appear( # finder.wait_for_appear(
|
|
149
|
+
object = 'Window title', # object = 'C://image_path', # object = 'Site Text', # object = '/xpath/',
|
|
150
|
+
type = 'window', # type = 'image', # type = 'text', # type = 'element',
|
|
151
|
+
timeout = 10 # timeout = 10 # timeout = 10 # timeout = 10
|
|
152
|
+
) # ) # ) # )
|
|
153
|
+
finder.wait_for_disappear() # Same thing
|
|
@@ -164,13 +164,6 @@ def invoke_api_proc_log(link, id_robo, token):
|
|
|
164
164
|
print(f"\n{responseinsert.json()}")
|
|
165
165
|
|
|
166
166
|
def login_2fac(driver, certificate, system, token, code_timeout=60):
|
|
167
|
-
from . import mostrar_mensagem
|
|
168
|
-
import time
|
|
169
|
-
import requests
|
|
170
|
-
import pyautogui
|
|
171
|
-
from selenium.webdriver.common.by import By
|
|
172
|
-
from selenium.webdriver.support.ui import WebDriverWait
|
|
173
|
-
from selenium.webdriver.support import expected_conditions as EC
|
|
174
167
|
|
|
175
168
|
class login_2fac:
|
|
176
169
|
def __init__(self):
|
|
@@ -251,7 +244,7 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
|
|
|
251
244
|
time.sleep(5)
|
|
252
245
|
continue
|
|
253
246
|
else:
|
|
254
|
-
|
|
247
|
+
raise('Todas as tentativas falharam!')
|
|
255
248
|
|
|
256
249
|
def invoke_update_status(self, id):
|
|
257
250
|
|
|
@@ -420,7 +413,6 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
|
|
|
420
413
|
break
|
|
421
414
|
|
|
422
415
|
if not(code_insertion):
|
|
423
|
-
mostrar_mensagem('Código WHOOM não chegou dentro do timeout estabelecido')
|
|
424
416
|
raise TimeoutError('Código WHOOM não chegou dentro do timeout estabelecido')
|
|
425
417
|
|
|
426
418
|
# Selects the system to access
|
|
@@ -475,20 +467,29 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
|
|
|
475
467
|
time.sleep(1)
|
|
476
468
|
if len(self.driver.window_handles) == num_windows:
|
|
477
469
|
try:
|
|
478
|
-
tools.find_element_with_wait(By.XPATH, "//button[text()='Acessar']").click()
|
|
470
|
+
tools.find_element_with_wait(By.XPATH, "//button[text()='Acessar']", timeout=1).click()
|
|
479
471
|
except:
|
|
480
472
|
break
|
|
481
473
|
else:
|
|
482
474
|
break
|
|
483
475
|
|
|
484
|
-
time.sleep(5)
|
|
485
476
|
handles = self.driver.window_handles
|
|
486
477
|
self.driver.switch_to.window(handles[-1])
|
|
487
478
|
protection.stop()
|
|
488
|
-
|
|
489
|
-
|
|
479
|
+
|
|
480
|
+
attempt = 0
|
|
481
|
+
while 'whoom' in self.driver.title.strip().lower() and attempt <= 180:
|
|
482
|
+
time.sleep(1)
|
|
483
|
+
attempt += 1
|
|
484
|
+
|
|
485
|
+
if attempt >= 180:
|
|
486
|
+
mostrar_mensagem('Whoom congelou no conectar com site.')
|
|
487
|
+
raise SystemError('Whoom congelou no conectar com site.')
|
|
488
|
+
|
|
489
|
+
if len(self.driver.window_handles) > 1:
|
|
490
|
+
self.driver.switch_to.window(self.driver.window_handles[0])
|
|
490
491
|
self.driver.close()
|
|
491
|
-
self.driver.switch_to.window(
|
|
492
|
+
self.driver.switch_to.window(self.driver.window_handles[-1])
|
|
492
493
|
|
|
493
494
|
# Instances
|
|
494
495
|
tools = tool()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|