bcpkgfox 0.17.2__tar.gz → 0.17.3__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.
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/PKG-INFO +1 -1
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox/invoke_api.py +13 -19
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox.egg-info/PKG-INFO +1 -1
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox.egg-info/SOURCES.txt +0 -2
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/setup.py +1 -1
- bcpkgfox-0.17.2/bcpkgfox/examples copy.py +0 -227
- bcpkgfox-0.17.2/bcpkgfox/examples.py +0 -153
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/README.md +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox/__init__.py +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox/clean.py +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox/cli.py +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox/find_elements.py +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox/get_driver.py +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox/system.py +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox.egg-info/dependency_links.txt +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox.egg-info/entry_points.txt +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox.egg-info/requires.txt +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/bcpkgfox.egg-info/top_level.txt +0 -0
- {bcpkgfox-0.17.2 → bcpkgfox-0.17.3}/setup.cfg +0 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
from selenium.webdriver.support import expected_conditions as EC
|
|
2
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
|
3
|
+
from selenium.webdriver.common.by import By
|
|
1
4
|
from typing import Optional
|
|
2
5
|
from threading import Thread
|
|
3
6
|
import time
|
|
7
|
+
import os
|
|
4
8
|
|
|
5
9
|
def invoke_api_list(link: str, token: str, method: Optional[str] = "GET", headers: Optional[str] = None, print_response: Optional[bool] = False) -> dict:
|
|
6
10
|
import requests
|
|
@@ -164,18 +168,9 @@ def invoke_api_proc_log(link, id_robo, token):
|
|
|
164
168
|
print(f"\n{responseinsert.json()}")
|
|
165
169
|
|
|
166
170
|
def login_2fac(driver, certificate, system, token, code_timeout=60):
|
|
167
|
-
|
|
168
|
-
from . import mostrar_mensagem
|
|
169
|
-
import bcpkgfox as bc
|
|
170
171
|
import requests
|
|
171
|
-
import time
|
|
172
172
|
import pyautogui
|
|
173
|
-
import
|
|
174
|
-
|
|
175
|
-
from threading import Thread
|
|
176
|
-
from selenium.webdriver.common.by import By
|
|
177
|
-
from selenium.webdriver.support.ui import WebDriverWait
|
|
178
|
-
from selenium.webdriver.support import expected_conditions as EC
|
|
173
|
+
from . import mostrar_mensagem
|
|
179
174
|
|
|
180
175
|
class login_2fac:
|
|
181
176
|
def __init__(self):
|
|
@@ -474,30 +469,29 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
|
|
|
474
469
|
raise ValueError('Mais de um sistema encontrado, verifique o nome')
|
|
475
470
|
|
|
476
471
|
# Verifies if the system was opened
|
|
477
|
-
|
|
478
|
-
for _ in range(5):
|
|
472
|
+
for _ in range(30):
|
|
479
473
|
time.sleep(1)
|
|
480
|
-
if len(self.driver.window_handles) ==
|
|
474
|
+
if len(self.driver.window_handles) == 1:
|
|
481
475
|
try:
|
|
482
476
|
tools.find_element_with_wait(By.XPATH, "//button[text()='Acessar']", timeout=1).click()
|
|
483
477
|
except:
|
|
484
|
-
|
|
478
|
+
time.sleep(1)
|
|
485
479
|
else:
|
|
480
|
+
time.sleep(3)
|
|
486
481
|
break
|
|
487
482
|
|
|
488
|
-
|
|
489
|
-
self.driver.switch_to.window(handles[-1])
|
|
490
|
-
protection.stop()
|
|
491
|
-
|
|
483
|
+
self.driver.switch_to.window(self.driver.window_handles[-1])
|
|
492
484
|
attempt = 0
|
|
493
485
|
while 'whoom' in self.driver.title.strip().lower() and attempt <= 180:
|
|
494
486
|
time.sleep(1)
|
|
495
487
|
attempt += 1
|
|
488
|
+
time.sleep(5)
|
|
496
489
|
|
|
497
490
|
if attempt >= 180:
|
|
498
491
|
mostrar_mensagem('Whoom congelou no conectar com site.')
|
|
499
492
|
raise SystemError('Whoom congelou no conectar com site.')
|
|
500
493
|
|
|
494
|
+
protection.stop()
|
|
501
495
|
if len(self.driver.window_handles) > 1:
|
|
502
496
|
self.driver.switch_to.window(self.driver.window_handles[0])
|
|
503
497
|
self.driver.close()
|
|
@@ -512,4 +506,4 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
|
|
|
512
506
|
# Operacional
|
|
513
507
|
bot.extension_check()
|
|
514
508
|
protection.start()
|
|
515
|
-
bot.codes_2_fac()
|
|
509
|
+
bot.codes_2_fac()
|
|
@@ -1,227 +0,0 @@
|
|
|
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()
|
|
@@ -1,153 +0,0 @@
|
|
|
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
|
|
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
|