bcpkgfox 0.16.65__tar.gz → 0.16.67__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcpkgfox
3
- Version: 0.16.65
3
+ Version: 0.16.67
4
4
  Summary: Biblioteca BCFOX
5
5
  Home-page: https://github.com/robotsbcfox/PacotePythonBCFOX
6
6
  Author: Guilherme Neri
@@ -225,7 +225,7 @@ def wait_for_element_disappear(object, type, timeout=10):
225
225
 
226
226
  return find_elements.backcode__dont_use__wait_for_d(driver, object, type, timeout=tempo)
227
227
 
228
- def selectfox(elemento, method, key, pure = None):
228
+ def selectfox(elemento, method, key, relative = None):
229
229
  """
230
230
  Seleciona uma opção em um elemento <select>.
231
231
 
@@ -233,6 +233,7 @@ def selectfox(elemento, method, key, pure = None):
233
233
  - elemento: Elemento <select> encontrado pelo Selenium.
234
234
  - method: Método de seleção ('index', 'text' ou 'value').
235
235
  - key: Valor usado na seleção (índice, texto visível ou valor do atributo 'value').
236
+ - relative: Ao invés de selecionar um elemento identico, seleciona um elemento que apenas contém a 'key'
236
237
 
237
238
  - Exemplo:
238
239
  elemento_select = bc.find_element_with_wait("xpath", '//select[@value="VALUE_DO_PRIMEIRO_SELECT"]')
@@ -264,12 +265,12 @@ def selectfox(elemento, method, key, pure = None):
264
265
  if method == "text":
265
266
  elements = select.options
266
267
  for elm in elements:
267
- if pure:
268
- if key == elm.text:
268
+ if relative:
269
+ if key.lower().strip() in elm.text.lower().strip():
269
270
  select.select_by_visible_text(elm.text)
270
271
  return
271
272
  else:
272
- if key.lower().strip() in elm.text.lower().strip():
273
+ if key == elm.text:
273
274
  select.select_by_visible_text(elm.text)
274
275
  return
275
276
 
@@ -262,17 +262,32 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
262
262
 
263
263
  except:
264
264
  self.driver.get('chrome-extension://lnidijeaekolpfeckelhkomndglcglhh/index.html')
265
+
265
266
  # Request the code
266
267
  for _ in range(50): # Wait the extension to load
267
268
 
268
269
  try:
269
- tools.find_element_with_wait(By.XPATH, '//*[@id="root"]/div/div[1]/div//div//input', timeout=1).send_keys('eliezer@bcfox.com.br')
270
+ tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Insira aqui o seu email"]', timeout=1).send_keys('eliezer@bcfox.com.br')
270
271
  time.sleep(1)
271
272
  break
272
273
  except:
273
274
  self.driver.get('chrome-extension://lnidijeaekolpfeckelhkomndglcglhh/index.html')
274
275
 
275
- tools.find_element_with_wait(By.XPATH, '//button').click()
276
+ # Envia o código pro email, o for é só para tratativa de bugs
277
+ for _ in range(10):
278
+ try:
279
+ tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Digite aqui o código que enviamos para o seu e-mail"]', timeout=1)
280
+ break
281
+
282
+ except:
283
+ try:
284
+ element = tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Insira aqui o seu email"]', timeout=1)
285
+ element.clear()
286
+ element.send_keys('eliezer@bcfox.com.br')
287
+ tools.find_element_with_wait(By.XPATH, '//button').click()
288
+ time.sleep(1)
289
+ except:
290
+ break
276
291
 
277
292
  # Attempts the new codes until success or requests limit
278
293
  for _ in range(code_timeout):
@@ -285,7 +300,10 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
285
300
  CODE = response['CODIGO']
286
301
  ID = response['ID']
287
302
 
288
- tools.find_element_with_wait(By.XPATH, '//input[@type="password"]').send_keys(CODE)
303
+ element = tools.find_element_with_wait(By.XPATH, '//input[@type="password"]')
304
+ element.clear()
305
+ element.send_keys(CODE)
306
+
289
307
  for _ in range(10):
290
308
  try:
291
309
  tools.find_element_with_wait(By.XPATH, '//div/div[2]/button', timeout=2).click()
@@ -294,7 +312,7 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
294
312
  break
295
313
 
296
314
  # Check the code result
297
- for _ in range(7):
315
+ for _ in range(30):
298
316
 
299
317
  # Correct
300
318
  try:
@@ -310,7 +328,7 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
310
328
  # Wrong
311
329
  try:
312
330
  tools.find_element_with_wait(By.XPATH, "//span[contains(text(), 'Senha inválida')]", timeout=1)
313
- tools.find_element_with_wait(By.XPATH, "//button[text()='Voltar']", timeout=1)
331
+ tools.find_element_with_wait(By.XPATH, "//button[text()='Voltar']", timeout=1).click()
314
332
  code_insertion = False
315
333
  break
316
334
 
@@ -329,15 +347,7 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
329
347
  raise TimeoutError('Código WHOOM não chegou dentro do timeout estabelecido')
330
348
 
331
349
  # Selects the system to access
332
- try:
333
- lines = tools.find_elements_with_wait(By.XPATH, '//*[@id="root"]/div[2]/div/div[1]/div/div[2]/div/div/div', timeout=5)
334
- except:
335
- try:
336
- lines = tools.find_elements_with_wait(By.XPATH, '//*[@id="root"]/div[2]/div/div[2]/div/div[2]/div/div/div', timeout=5)
337
- except Exception as e:
338
- mostrar_mensagem('Não conseguiu achar o sistema no certificado')
339
- print(f'{e}\n\n\n\n\n\n')
340
- raise ValueError('Não conseguiu achar o sistema no certificado') from e
350
+ lines = tools.find_elements_with_wait(By.XPATH, '//div[@role="menu"]//div[@role="menuitem"]')
341
351
 
342
352
  finded = False
343
353
  div_list = []
@@ -402,42 +412,45 @@ def login_2fac(driver, certificate, system, token, code_timeout=60):
402
412
 
403
413
  self.driver.get('chrome-extension://lnidijeaekolpfeckelhkomndglcglhh/index.html')
404
414
 
405
- try:
406
- tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Digite ou selecione um sistema pra acessar"]', timeout=10).send_keys(self.system)
407
- return
415
+ for _ in range(10):
408
416
 
409
- except Exception as e:
417
+ # Caso a extensão já esteja instalada
418
+ try:
419
+ tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Digite ou selecione um sistema pra acessar"]', timeout=1).send_keys(self.system)
420
+ return
421
+ except: pass
422
+
423
+ # Caso a extensão não esteja instala
424
+ if 'This page has been blocked by Chrome' in driver.page_source:
425
+ break
410
426
 
411
427
  if 'eliezer@bcfox.com.br' in self.driver.page_source:
412
428
  tools.find_element_with_wait(By.XPATH, "//span[text()='alterar']").click()
413
429
  return
414
430
 
415
- # Abrir uma nova aba
416
- self.driver.execute_script("window.open('');")
431
+ # Abrir uma nova aba
432
+ self.driver.execute_script("window.open('');")
417
433
 
418
- # Fechar a aba original
419
- self.driver.close()
434
+ # Fechar a aba original
435
+ self.driver.close()
420
436
 
421
- # Mudar para a nova aba
422
- self.driver.switch_to.window(self.driver.window_handles[-1])
437
+ # Mudar para a nova aba
438
+ self.driver.switch_to.window(self.driver.window_handles[-1])
423
439
 
424
- time.sleep(1)
440
+ time.sleep(1)
425
441
 
426
- self.driver.get("https://chromewebstore.google.com/detail/whom-gerenciador-de-certi/lnidijeaekolpfeckelhkomndglcglhh")
442
+ self.driver.get("https://chromewebstore.google.com/detail/whom-gerenciador-de-certi/lnidijeaekolpfeckelhkomndglcglhh")
427
443
 
428
- try:
429
- tools.find_element_with_wait(By.XPATH, "//span[contains(text(), 'no Chrome') or contains(text(), 'Usar') or contains(text(), 'Add to Chrome')]").click()
430
- except Exception as e:
431
- return
432
- time.sleep(5)
444
+ tools.find_element_with_wait(By.XPATH, "//span[contains(text(), 'no Chrome') or contains(text(), 'Usar') or contains(text(), 'Add to Chrome')]").click()
445
+ time.sleep(5)
433
446
 
434
- # Envia TAB e ENTER do teclado físico
435
- pyautogui.press('tab')
436
- time.sleep(0.5)
437
- pyautogui.press('enter')
438
- time.sleep(5)
447
+ # Envia TAB e ENTER do teclado físico
448
+ pyautogui.press('tab')
449
+ time.sleep(0.5)
450
+ pyautogui.press('enter')
451
+ time.sleep(5)
439
452
 
440
- self.driver.get('chrome-extension://lnidijeaekolpfeckelhkomndglcglhh/index.html')
453
+ self.driver.get('chrome-extension://lnidijeaekolpfeckelhkomndglcglhh/index.html')
441
454
 
442
455
  tools = tool()
443
456
  api = invokes_whoom()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcpkgfox
3
- Version: 0.16.65
3
+ Version: 0.16.67
4
4
  Summary: Biblioteca BCFOX
5
5
  Home-page: https://github.com/robotsbcfox/PacotePythonBCFOX
6
6
  Author: Guilherme Neri
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="bcpkgfox",
5
- version="0.16.65",
5
+ version="0.16.67",
6
6
  author="Guilherme Neri",
7
7
  author_email="guilherme.neri@bcfox.com.br",
8
8
  description="Biblioteca BCFOX",
File without changes
File without changes
File without changes
File without changes