-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgoritimo.py
4795 lines (4381 loc) · 252 KB
/
algoritimo.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from check_tr import check_tr
from bibliotecas import *
check_tr()
sg.popup_notify(f'Carregando biblioteca...')
esperar = time.sleep(.05)
esperar1 = time.sleep(1)
esperar2 = time.sleep(2)
esperar3 = time.sleep(.01)
esperar4 = time.sleep(3)
esperar5 = time.sleep(3.5)
class Internet:
def __init__(self):
pass
def navegador_driver(self,usar_edge=True,usar_chrome=True,usar_Iexplorer=True,usar_interno=True):
# Verifica qual browser será utilizado e inicia o serviço correspondente
if usar_edge:
service = EdgeService()
#self.driver = Edge(executable_path=EdgeDriverManager().install())
elif usar_chrome:
self.driver = Chrome(executable_path=ChromeDriverManager().install())
elif usar_Iexplorer:
service = IEService()
self.driver = Ie(executable_path=IEDriverManager().install())
else:
self.driver = Firefox(executable_path=GeckoDriverManager().install())
# Maximiza a janela do navegador
self.driver.maximize_window()
# Abre a página inicial do sistema
if usar_interno: #interno
self.driver.get("http://netwin-vtal.interno/")
else: #externo
self.driver.get("http://netwin.intranet/")
# Define um tempo de espera implícito para aguardar a página carregar completamente
self.driver.implicitly_wait(20)
def entrar_driver(self, login = True):
# Espera por até 60 segundos para a página carregar completamente
wdw = WebDriverWait(self.driver, 60)
# Carrega as credenciais a partir do arquivo "credenciais.json"
with open("credenciais.json", encoding='utf-8') as meu_json:
dado = json.load(meu_json)
# Define uma função para preencher os campos de login e senha
def preencher_campo(elemento,texto):
# Espera até que o elemento esteja clicável
wdw.until(element_to_be_clickable(('id', elemento)))
# Seleciona o campo de texto
campo = self.driver.find_element(By.ID, elemento)
# Limpa o campo de texto
campo.clear()
# Insere o texto no campo
campo.send_keys(texto)
# Preenche o campo de login e o campo de senha
preencher_campo('inputLogin',dado['login'])
preencher_campo('inputPassword',dado['senha'])
def esperar_clicar_ID(self,elemento):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(EC.element_to_be_clickable(('id', elemento)))
self.driver.find_element(By.ID,elemento).click()
except:
pass
def esperar_clicar_xpath(self,elemento):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(EC.element_to_be_clickable((By.XPATH, elemento)))
self.driver.find_element(By.XPATH,elemento).click()
except:
pass
def esperar_txt_ID(self,elemento, txt):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(element_to_be_clickable(('id', elemento)))
self.driver.find_element(By.ID,elemento).clear()
self.driver.find_element(By.ID,elemento).send_keys(txt)
except:
pass
def esperar_link_txt(self,elemento):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(element_to_be_clickable(('link text', elemento)))
self.driver.find_element(By.LINK_TEXT,elemento).click()
except:
pass
def esperar_selecionar_ID(self,elemento, value):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until((element_to_be_clickable(('id', elemento))))
selecionar = Select(self.driver.find_element(By.ID,elemento))
esperar
selecionar.select_by_value(value)
except:
pass
def esperar_selecionar_value(self,elemento, value):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until((element_to_be_clickable(('id', elemento))))
selecionar = Select(self.driver.find_element(By.ID,elemento))
esperar
selecionar.select_by_value(value)
except:
pass
def esperar_selecionar_value_xpath(self,elemento, value):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until((element_to_be_clickable(('xpath', elemento))))
selecionar = Select(self.driver.find_element(By.ID,elemento))
esperar
selecionar.select_by_value(value)
except:
pass
def esperar_selecionar_ID_txt(self,elemento,txt):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(element_to_be_clickable(('id', elemento)))
self.driver.find_element(By.ID,elemento).clear()
self.driver.find_element(By.ID,elemento).send_keys(txt)
esperar2
self.driver.find_element(By.ID,elemento).send_keys(Keys.ENTER)
except:
pass
def iframe(self,elemento):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(frame_to_be_available_and_switch_to_it((
'id',elemento)))
except:
sg.popup_error('i carai\nnem encontrou oque vc queria, tem que reiniciar o programa',keep_on_top=True)
exit()
def esperar_xpath_txt(self,elemento,txt):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(element_to_be_clickable(('xpath', elemento)))
time.sleep(.15)
self.driver.find_element(By.XPATH,elemento).clear()
self.driver.find_element(By.XPATH,elemento).send_keys(txt)
except:
pass
def esperar_selecionar_index(self,elemento,num):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(element_to_be_clickable(('id', elemento)))
selecionar = Select(self.driver.find_element(By.ID,elemento))
selecionar.select_by_index(num)
except:
pass
def esperar_xpath(self,elemento):
try:
wdw = WebDriverWait(self.driver, 60)
wdw.until(element_to_be_clickable(('xpath', elemento)))
esperar
self.driver.find_element(By.XPATH,elemento).click()
except:
pass
def procurar_estação(self,elemento,procurar=True):
if procurar:
self.esperar_xpath('//a[@data-module="Outside Plant"]')
self.iframe('iframe-content-wrapper')
self.iframe('ifrarvore')
self.iframe('ifArvore')
self.esperar_clicar_ID('sigrede_1_0_2_2_txt')
self.driver.switch_to.default_content()
self.iframe('iframe-content-wrapper')
self.iframe('ifrarvore')
self.iframe('ifPesquisa')
self.esperar_selecionar_ID_txt('searchName',elemento)
esperar
self.driver.switch_to.default_content()
else:
self.iframe('iframe-content-wrapper')
self.iframe('ifrarvore')
self.iframe('ifPesquisa')
esperar
self.esperar_selecionar_ID_txt('searchName',elemento)
esperar
self.driver.switch_to.default_content()
esperar
#menu_op_ico
self.driver.find_element(By.CSS_SELECTOR, ".odd > #tdresultado").click()
self.driver.switch_to.frame(1)
element = self.driver.find_element(By.CSS_SELECTOR, "#sigrede_1_0_2_4 > .menu_op_txt")
actions = ActionChains(self.driver)
actions.move_to_element(element).perform()
element = self.driver.find_element(By.CSS_SELECTOR, "body")
actions = ActionChains(self.driver)
actions.move_to_element(element, 0, 0).perform()
self.driver.execute_script("window.scrollTo(0,0)")
self.driver.find_element(By.CSS_SELECTOR, "#sigrede_1_0_2_13_3_1845911_4_1853370_191_793569_ico > img").click()
self.driver.find_element(By.ID, "nodefault_1").click()
self.driver.switch_to.default_content()
self.driver.find_element(By.CSS_SELECTOR, ".olControlCellButtonItemInactive").click()
self.driver.find_element(By.ID, "olControlGPONCell").click()
self.driver.find_element(By.ID, "olControlViewCell").click()
self.driver.find_element(By.ID, "searchLocation").click()
dropdown = self.driver.find_element(By.ID, "searchLocation")
dropdown.find_element(By.XPATH, "//option[. = 'CPBA - BANDEIRANTES']").click()
self.driver.find_element(By.ID, "searchCellD").click()
dropdown = self.driver.find_element(By.ID, "searchCellD")
dropdown.find_element(By.XPATH, "//option[. = '480']").click()
self.driver.switch_to.default_content()
def cdoe_precon(self,id_sicon,estação,numero,est=True,confirmar=True,frame=True,sap=True,sap_1=True,campo=True,tbd=True,projeto=True):
#Esperando até seja visivel as Iframe da pagina
if frame:
self.iframe('iframe-content-wrapper')
else:
pass
try:
self.iframe('externalIspIframe')
self.iframe('dados')
wdw = WebDriverWait(self.driver, 60)
wdw.until(element_to_be_clickable(('xpath', '//*[@id="idTipoElemento"]')))
objeto_aereo = self.driver.find_element(By.XPATH,'//*[@id="idTipoElemento"]').text
if objeto_aereo == ' CDOE' or objeto_aereo == 'CDOE':
self.esperar_clicar_ID('id_sicom_name')
#Tipo
if confirmar:
self.esperar_selecionar_ID('elem_tipo.outroNomeEquip','CAIXA DIST OPT SEL 9 SC EXT SLIM 1:8')
elif sap:
self.esperar_selecionar_ID('elem_num_sap','331995') #1:8 final
elif sap_1:
self.esperar_selecionar_ID('elem_num_sap','331688') #1:8 intermediaria
else:
self.esperar_selecionar_ID('elem_tipo.outroNomeEquip','CAIXA DIST OPT SEL 10 SC EXT SLIM 30/70')
#Rede
self.esperar_selecionar_ID('network','Óptica GPON')
if projeto:
#Id-sicon
self.esperar_txt_ID('id_sicom_name',id_sicon)
self.esperar_xpath('//li[@class="ac_even ac_over"]')
else:
#Nome projeto
self.esperar_txt_ID('projecto_name',id_sicon)
self.esperar_xpath('/html/body/div[*]/ul/li/strong')
if campo:
#Identif. campo
self.esperar_selecionar_ID('nameCampId','Existente - Não Validado')
else:
#Identif. campo
self.esperar_selecionar_ID('nameCampId','Existente - Conforme')
#Estação abastecedora 1
if est:
#identiicar local para escrita/escrever , confirmar
self.esperar_selecionar_ID_txt('supplierStationName',estação)
self.esperar_xpath('//li[@class="ac_even ac_over"]')
else:
pass
#Topologia
self.esperar_selecionar_ID('topology','A/B')
time.sleep(.05)
#Estações Abastecedoras 2
self.driver.find_element(By.LINK_TEXT,'Estações abastecedoras').click()
self.esperar_txt_ID('autocompleteSLocation',estação)
self.esperar_xpath('//li[@class="ac_even ac_over"]')
self.esperar_clicar_ID('adicionar')
#Rastreabilidade
self.driver.find_element(By.LINK_TEXT,'Rastreabilidade').click()
self.esperar_selecionar_ID('sourceId','Netwin')
#caracteristica
self.esperar_clicar_xpath('/html/body/table/tbody/tr/td/div/div/div/form/div/table/tbody/tr[*]/td/div/ul/li[1]/a/span')
if tbd:
self.esperar_xpath_txt('//*[@id="nomecNumber"]', numero)
else:
#tbd
self.esperar_clicar_xpath('//*[@id="outOfPattern_check"]') #fora de padrão
time.sleep(1)
self.esperar_xpath('//*[@id="onPatternTag"]')
'''
time.sleep(1)
etiqueta_padrao = self.driver.find_element(By.XPATH,'//*[@id="onPatternTag"]').text()
'''
time.sleep(.5)
self.esperar_xpath_txt('//*[@id="tagOnField"]','CDOE-'+ numero +'-TBD')
self.esperar_xpath_txt('//*[@id="nomecNumber"]', '0')
#Confimar
self.esperar_clicar_ID('confAssoc')
#Sair
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
except:
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
sg.popup_error(f'Ixi deu um erro ae O_O \nse pa você ta no caminho errado ou \nnão é a CDOE',keep_on_top=True)
def cdoe_precon_2022(self,id_sicon,estação,numero,est=True,confirmar=True,frame=True,precom_rs=True,tbd=True,projeto=True,):
#Esperando até seja visivel as Iframe da pagina
if frame:
self.iframe('iframe-content-wrapper')
else:
pass
try:
self.iframe('externalIspIframe')
self.iframe('dados')
wdw = WebDriverWait(self.driver, 60)
wdw.until(element_to_be_clickable(('xpath', '//*[@id="idTipoElemento"]')))
objeto_aereo = self.driver.find_element(By.XPATH,'//*[@id="idTipoElemento"]').text
print(objeto_aereo)
if objeto_aereo == 'CDOE' or objeto_aereo == ' CDOE':
self.esperar_clicar_ID('id_sicom_name')
#Tipo
if confirmar:
self.esperar_selecionar_ID('elem_tipo.outroNomeEquip','CAIXA DISTR OPT SEL 18 SC EXT TAP 30/70')
else:
self.esperar_selecionar_ID('elem_tipo.outroNomeEquip','CAIXA DISTR OPT SEL 17 SC EXT TAP 1:16')
#Rede
self.esperar_selecionar_ID('network','Óptica GPON')
if projeto:
#Id-sicon
self.esperar_txt_ID('id_sicom_name',id_sicon)
self.esperar_xpath('//li[@class="ac_even ac_over"]')
else:
#Nome projeto
self.esperar_txt_ID('projecto_name',id_sicon)
self.esperar_xpath('/html/body/div[*]/ul/li/strong')
if precom_rs:
#Identif. campo
self.esperar_selecionar_ID('nameCampId','Desconhecido')
else:
#Identif. campo
self.esperar_selecionar_ID('nameCampId','Existente - Conforme')
#Estação abastecedora 1
if est:
#identiicar local para escrita/escrever , confirmar
self.esperar_selecionar_ID_txt('supplierStationName',estação)
esperar
self.esperar_xpath('//li[@class="ac_even ac_over"]')
else:
#identiicar local para escrita/escrever , confirmar
self.esperar_selecionar_ID_txt('supplierStationName',estação)
esperar
self.esperar_xpath('//li[@class="ac_odd"]')
#Topologia
self.esperar_selecionar_ID('topology','A/B')
#Estações Abastecedoras 2
if est:
self.esperar_link_txt('Estações abastecedoras')
self.esperar_txt_ID('autocompleteSLocation',estação)
self.esperar_xpath('//li[@class="ac_even ac_over"]')
self.esperar_clicar_ID('adicionar')
else:
self.esperar_link_txt('Estações abastecedoras')
self.esperar_txt_ID('autocompleteSLocation',estação)
esperar1
self.esperar_xpath('//li[@class="ac_odd ac_over"]')
self.esperar_clicar_ID('adicionar')
#Rastreabilidade
self.esperar_link_txt('Rastreabilidade')
self.esperar_selecionar_ID('sourceId','Netwin')
#caracteristica
self.esperar_clicar_xpath('/html/body/table/tbody/tr/td/div/div/div/form/div/table/tbody/tr[*]/td/div/ul/li[1]/a/span')
if tbd:
self.esperar_xpath_txt('//*[@id="nomecNumber"]', numero)
else:
#tbd
self.esperar_clicar_xpath('//*[@id="outOfPattern_check"]') #fora de padrão
time.sleep(1)
self.esperar_xpath('//*[@id="onPatternTag"]')
'''
time.sleep(1)
etiqueta_padrao = self.driver.find_element(By.XPATH,'//*[@id="onPatternTag"]').text()
'''
time.sleep(.5)
self.esperar_xpath_txt('//*[@id="tagOnField"]','CDOE-'+ numero +'-TBD')
self.esperar_xpath_txt('//*[@id="nomecNumber"]', '0')
#Confimar
self.esperar_clicar_ID('confAssoc')
#Sair
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
except:
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
sg.popup_error(f'Ixi deu um erro ae O_O \nse pa você ta no caminho errado ou \nnão é a CDOE',keep_on_top=True)
def cdoe_comun(self, id_sicon, estação, numero=randint, confimar = False, confirmar_quebra = True):
wdw = WebDriverWait(self.driver, 30)
if confirmar_quebra:
self.iframe('iframe-content-wrapper')
#adicionar
self.esperar_xpath('//div[@class="olControlIndoorMapAddButtonItemInactive"]')
#equipamento
self.esperar_clicar_ID('olControlAddEquipment')
#fibra optica
self.esperar_xpath('/html/body/div[3]/div[1]/div[2]/div[2]/div/div/fieldset/ul/li[1]/a/div[2]')
#CDO
self.esperar_xpath('/html/body/div[3]/div[1]/div[2]/div[2]/div/div/fieldset/ul/li[1]/ul/li[1]/a/div[2]')
#CDOE
self.esperar_xpath('/html/body/div[3]/div[1]/div[2]/div[2]/div/div/fieldset/ul/li[1]/ul/li[1]/ul/li[1]/a/div[2]')
#clicar para criação do equipamento
pt.click(x=1662, y=758) #esquerdo
pt.rightClick(x=1725, y=736) #direito
time.sleep(1)
else:
if confirmar_quebra:
pass
else:
self.iframe('iframe-content-wrapper')
time.sleep(1)
self.iframe('externalIspIframe')
self.iframe('dados')
#esperar um tempo para carregar iframe
self.esperar_clicar_ID('id_sicom_name')
#Tipo
if confimar:
self.esperar_selecionar_ID('elem_tipo.outroNomeEquip','CDOE 8-48FS C/ SPL 1:8 OPTITAP COR/TOP/FACH')
else:
self.esperar_selecionar_ID('elem_tipo.outroNomeEquip','CDOE 16-48FS C/ SPL 2 x 1:8 OPTITAP COR/TOP/FACH')
#Rede
self.esperar_selecionar_ID('network','Óptica GPON')
#Fabricante
self.esperar_selecionar_ID('idFabricante','CORNING')
#Id-sicon
self.esperar_txt_ID('id_sicom_name',id_sicon)
self.esperar_xpath('//li[@class="ac_even ac_over"]')
#Estação abastecedora/predial
#navegador.esperar_clicar('suppStationFilterButton')
#navegador.esperar_selecionar_txt('estacao', estação)
#navegador.esperar_clicar('imgListaRelEquipamento')
self.esperar_txt_ID('supplierStationName', estação)
self.esperar_xpath('//li[@class="ac_even ac_over"]')
#Topologia
self.esperar_selecionar_ID('topology','A/B')
#Identif. campo
self.esperar_selecionar_ID('nameCampId','Existente - Não Validado')
#numero
self.esperar_txt_ID('nomecNumber',numero)
time.sleep(.15)
#Estações Abastecedoras
self.esperar_link_txt('Estações abastecedoras')
self.esperar_txt_ID('autocompleteSLocation', estação)
self.esperar_xpath('//li[@class="ac_even ac_over"]')
self.esperar_clicar_ID('adicionar')
#Rastreabilidade
self.esperar_link_txt('Rastreabilidade')
self.esperar_selecionar_ID('sourceId','Netwin')
#Confimar
self.esperar_clicar_ID('confAssoc')
#Sair
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
time.sleep(1)
#Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
def componentes(self,modelo=True):
self.iframe('iframe-content-wrapper')
self.iframe('externalIspIframe')
self.iframe('dados')
#componetes
self.esperar_xpath('/html/body/table/tbody/tr/td/div/div/div/form/div/table/tbody/tr[*]/td/div/ul/li[4]/a/span')
#+
self.esperar_clicar_ID('addNoPosComp')
time.sleep(1)
self.iframe('targetIframe')
if modelo:
#modelo
self.esperar_selecionar_value('idTipoElemento','20748') #1:8
time.sleep(.1)
#legado
self.esperar_selecionar_value('LEGADO','NÃO')
time.sleep(.1)
#confirmar
esperar1
self.esperar_clicar_ID('confAssoc')
esperar1
#fechar
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
self.driver.switch_to.default_content()
else:
#modelo
self.esperar_selecionar_value('idTipoElemento','20726') #1:8
time.sleep(.1)
#legado
self.esperar_selecionar_value('LEGADO','NÃO')
time.sleep(.1)
#confirmar
esperar1
self.esperar_clicar_ID('confAssoc')
esperar1
#fechar
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
time.sleep(1)
self.driver.switch_to.default_content()
self.iframe('iframe-content-wrapper')
self.iframe('externalFrame')
self.iframe('dados')
#+
self.esperar_clicar_ID('addNoPosComp')
self.iframe('targetIframe')
#modelo
self.esperar_selecionar_value('idTipoElemento','20725') #1:2
time.sleep(.1)
#legado
self.esperar_selecionar_value('LEGADO','NÃO')
time.sleep(.1)
#confirmar
esperar1
self.esperar_clicar_ID('confAssoc')
esperar1
#fechar
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
self.driver.switch_to.default_content()
self.iframe('iframe-content-wrapper')
self.esperar_xpath('/html/body/div[*]/div[*]/a[1]/span')
self.driver.switch_to.default_content()
def componentes_2022(self,modelo=True):
self.iframe('iframe-content-wrapper')
self.iframe('externalIspIframe')
self.iframe('dados')
#componetes
self.esperar_xpath('/html/body/table/tbody/tr/td/div/div/div/form/div/table/tbody/tr[*]/td/div/ul/li[4]/a/span')
#+
self.esperar_clicar_ID('addNoPosComp')
time.sleep(1)
self.iframe('targetIframe')
if modelo:
#modelo
self.esperar_selecionar_value('idTipoElemento','20723') #1:16
time.sleep(1.5)
#legado
self.esperar_selecionar_value('LEGADO','NÃO')
time.sleep(1.5)
#confirmar
time.sleep(1.5)
self.esperar_clicar_ID('confAssoc')
esperar1
#fechar
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
self.driver.switch_to.default_content()
else:
#modelo
self.esperar_selecionar_value('idTipoElemento','20752') #1:16
time.sleep(1.5)
#legado
self.esperar_selecionar_value('LEGADO','NÃO')
time.sleep(1.5)
#confirmar
esperar1
self.esperar_clicar_ID('confAssoc')
esperar1
#fechar
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
time.sleep(1)
self.driver.switch_to.default_content()
self.iframe('iframe-content-wrapper')
self.iframe('externalFrame')
self.iframe('dados')
#+
self.esperar_clicar_ID('addNoPosComp')
self.iframe('targetIframe')
#modelo
self.esperar_selecionar_value('idTipoElemento','20727') #1:2
time.sleep(1.5)
#legado
self.esperar_selecionar_value('LEGADO','NÃO')
time.sleep(1.5)
#confirmar
esperar1
self.esperar_clicar_ID('confAssoc')
esperar1
#fechar
self.esperar_xpath('/html/body/div[*]/div/div/table/tbody/tr/td[3]/button')
self.driver.switch_to.default_content()
self.iframe('iframe-content-wrapper')
self.esperar_xpath('/html/body/div[*]/div[*]/a[1]/span')
self.driver.switch_to.default_content()
def conectividade(self,spliter=True,mod=True):
wdw = WebDriverWait(self.driver, 60)
self.iframe('iframe-content-wrapper')
self.iframe('externalFrame')
try:
if spliter:
#cenario
self.esperar_selecionar_value('cbScenario','difusion') #Fibra óptica 1:1 Splitter n:n Fibra óptica
wdw.until(element_to_be_clickable(('id', 'splitter_ratio_inout_2main')))
self.esperar_clicar_ID('splitter_ratio_inout_2main')
#cabo
self.esperar_selecionar_index('cable_inout_1main',1)
#fibra
self.esperar_selecionar_value('fiber_inout_1main','1')
if mod:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_2main',1) #1/2
else:
self.esperar_selecionar_index('splitter_ratio_inout_2main',2) #1/2
#porta de entrada
self.esperar_selecionar_index('splitter_port_in_2main',1)
#porta saida inicial
self.esperar_selecionar_index('splitter_port_out_2main',1)
#cabo
self. esperar_selecionar_index('cable_inout_3main',1)
#Fibra Inicial
self.esperar_selecionar_index('fiber_inout_3main',1)
#ligar
self.esperar_clicar_ID('connectButton')
#confirmar
self.esperar_clicar_ID('attributesConfirmButton')
time.sleep(1)
#OK
self.esperar_xpath('//*[@class="linkbutton no-image confirm button"]')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
else:
self.esperar_selecionar_value('cbScenario','doubledifusion_pdo') #Fibra óptica 1:1 Splitter 1:1 Splitter n:n Porta CDO
time.sleep(2)
#cabo
self.esperar_selecionar_index('cable_inout_1main',1)
#fibra
self.esperar_selecionar_value('fiber_inout_1main','1')
if mod:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_2main',1) #1/2
else:
self.esperar_selecionar_index('splitter_ratio_inout_2main',2) #1/2
#porta de entrada
self.esperar_selecionar_index('splitter_port_in_2main',1)
#porta saida
self.esperar_selecionar_index('splitter_port_out_2main',2)
if mod:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_3main',2) #1:8
else:
self.esperar_selecionar_index('splitter_ratio_inout_3main',1) #1:8
#porta entrada
self.esperar_selecionar_index('splitter_port_in_3main',1)
#porta saida inicial
self.esperar_selecionar_index('splitter_port_out_3main',1)
#porta saida final
self.esperar_selecionar_index('splitter_port_out_3main_final',8)
#porta inicial
self.esperar_selecionar_index('pdoport_inout_4main',1)
#porta final
self.esperar_selecionar_index('pdoport_inout_4main_final',8)
#ligar
self.esperar_clicar_ID('connectButton')
#tipo ligador
self.esperar_selecionar_value('link_LinkConnectionPhysicalType_2','FO.PIGTAIL')
#tipo ligador
self.esperar_selecionar_value('link_LinkConnectionPhysicalType_3','FO.PIGTAIL')
time.sleep(1)
#confirmar
self.esperar_clicar_ID('attributesConfirmButton')
#x
#self.esperar_xpath('//*[@id="closeButton"]')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
except:
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
sg.popup_error(f'Ixi deu um erro ae O_O \nse pa você ta no caminho errado ou \nnão é a CONECTIVIDADE 1:8',keep_on_top=True)
def conectividade_2022(self,spliter=True,ratio=True,iframe=True):
if iframe:
wdw = WebDriverWait(self.driver, 60)
self.iframe('iframe-content-wrapper')
self.iframe('externalFrame')
else:
pass
try:
if spliter:
#cenario
self.esperar_selecionar_value('cbScenario','difusion') #Fibra óptica 1:1 Splitter n:n Fibra óptica
wdw.until(element_to_be_clickable(('id', 'splitter_ratio_inout_2main')))
self.esperar_clicar_ID('splitter_ratio_inout_2main')
#cabo
self.esperar_selecionar_index('cable_inout_1main',1)
#fibra
self.esperar_selecionar_value('fiber_inout_1main','1')
if ratio:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_2main',2) #1:16
else:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_2main',1) #1:16
#porta de entrada
self.esperar_selecionar_index('splitter_port_in_2main',1)
#porta saida inicial
self.esperar_selecionar_index('splitter_port_out_2main',1)
#cabo
self. esperar_selecionar_index('cable_inout_3main',1)
#Fibra Inicial
self.esperar_selecionar_index('fiber_inout_3main',1)
#ligar
self.esperar_clicar_ID('connectButton')
#confirmar
self.esperar_clicar_ID('attributesConfirmButton')
#OK
self.esperar_xpath('//*[@class="linkbutton no-image confirm button"]')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
else:
self.esperar_selecionar_value('cbScenario','doubledifusion_pdo') #Fibra óptica 1:1 Splitter 1:1 Splitter n:n Porta CDO
time.sleep(2)
#cabo
self.esperar_selecionar_index('cable_inout_1main',1)
#fibra
self.esperar_selecionar_value('fiber_inout_1main','1')
if ratio:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_2main',2) #1:2
else:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_2main',1) #1:2
#porta de entrada
self.esperar_selecionar_index('splitter_port_in_2main',1)
#porta saida
self.esperar_selecionar_index('splitter_port_out_2main',2)
if ratio:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_3main',1) #1:16
else:
#spliter
self.esperar_selecionar_index('splitter_ratio_inout_3main',2) #1:16
#porta entrada
self.esperar_selecionar_index('splitter_port_in_3main',1)
#porta saida inicial
self.esperar_selecionar_index('splitter_port_out_3main',1)
#porta saida final
self.esperar_selecionar_index('splitter_port_out_3main_final',16)
#porta inicial
self.esperar_selecionar_index('pdoport_inout_4main',1)
#porta final
self.esperar_selecionar_index('pdoport_inout_4main_final',16)
#ligar
self.esperar_clicar_ID('connectButton')
#tipo ligador
self.esperar_selecionar_value('link_LinkConnectionPhysicalType_2','FO.PIGTAIL')
#tipo ligador
self.esperar_selecionar_value('link_LinkConnectionPhysicalType_3','FO.PIGTAIL')
#confirmar
self.esperar_clicar_ID('attributesConfirmButton')
#x
#self.esperar_xpath('//*[@class="ui-icon ui-icon-closethick"]')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
except:
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
sg.popup_error(f'Ixi deu um erro ae O_O \nse pa você ta no caminho errado ou \nnão é a CONECTIVIDADE 1:16',keep_on_top=True)
def mudar_status_cabo_completo(self):
wdw = WebDriverWait(self.driver, 60)
self.iframe('iframe-content-wrapper')
#modificar
self.esperar_xpath('/html/body/div[*]/div[2]/div[2]/div[15]')
#script para controlar a ação do mouse em seguida de repetição da ação *clique/local
def on_click(x, y,button,pressed):
if button == mouse.Button.left and pressed:
# Retornar False para a execução do listener de eventos
return False
# Listener irá verificar quando o mouse clicará
with mouse.Listener(on_click=on_click) as listener:
while True:
# Assim que o mouse clicar, o listener irá encerrar e parar o loop
if not listener.running:
break
#definição da posição do mouse
x, y = pt.position()
time.sleep(2.2)
#implantação concluida
self.esperar_selecionar_ID('catProjectStateId','191')
time.sleep(.5)
#guardar
self.esperar_xpath('/html/body/div[*]/div[3]/div/button[1]')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
time.sleep(1.7)
print(pt.click(x, y))
#entrar no iframe
self.iframe('iframe-content-wrapper')
time.sleep(1.5)
#as-built
self.esperar_clicar_ID('lot')
esperar1
self.esperar_clicar_ID('asBuilt')
#estado de projeto
self.esperar_selecionar_value('catProjectStateId','194')
esperar1
#guardar
self.esperar_xpath('/html/body/div[*]/div[3]/div/button[1]')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
def sob_demanda(self):
self.iframe('iframe-content-wrapper')
#sob demanda
self.esperar_selecionar_value('catProjectStateId','190')
#instalação futura
self.esperar_clicar_ID('futureInstall')
time.sleep(.5)
#guardar
self.esperar_xpath('/html/body/div[*]/div[3]/div/button[1]')
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
def encontrar(self,elemento):
wdw = WebDriverWait(self.driver, 60)
self.iframe('iframe-content-wrapper')
#entidade
self.esperar_selecionar_value('rede','EQUIPMENT')
#tipo
self.esperar_selecionar_value('tipo','515')
#Nome
self.esperar_txt_ID('codigo',elemento)
#resultado
time.sleep(5)
wdw.until(element_to_be_clickable(('xpath', '//*[@aria-describedby="pesquisaGrid_code"]')))
time.sleep(1)
pt.click(x=233, y=476)
# Retorna para a janela principal (fora do iframe)
self.driver.switch_to.default_content()
def endereco(procurar = True):
if procurar:
sg.theme('Reddit')
local = sg.popup_get_folder(r'Selecione o caminho dos Arquivos')
caminho = os.chdir(local)
else:
pass
return caminho
def poste (self,poste,cap,id_sicom,origem=True,proprietario=True,tr=True,padrao=True,origem_rs=True,tipo=True,id=True):
wdw = WebDriverWait(self.driver, 60)
try:
# Esperando até seja visivel as Iframe da pagina
self.iframe('iframe-content-wrapper')
self.iframe('externalLocationIframe')
if padrao:
pass
else:
#Fora de padão
time.sleep(.05)
self.esperar_clicar_ID('location_input_FORA_PADRAO')
#Capacidade (Altura/Esforço)
self.esperar_xpath('//span[@id="select2-location_select_poleCapacity-container"]')
self.esperar_xpath_txt('//input[@class="select2-search__field"]',poste)
self.esperar_xpath('//li[@class="select2-results__option select2-results__option--highlighted"]')
if padrao:
#Identificação em campo
self.esperar_xpath('//span[@id="select2-location_select_fieldId-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Existente - Não Validado')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
else:
#Identificação em campo
self.esperar_xpath('//span[@id="select2-location_select_fieldId-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Existente - Conforme')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
if tipo:
#tipo
self.esperar_xpath('//*[@id="select2-location_select_poleType-container"]/span')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('CONCRETO/DUPLO T')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
else:
#tipo
self.esperar_xpath('//*[@id="select2-location_select_poleType-container"]/span')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('CONCRETO/CIRCULAR')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
#transformador
if tr:
self.esperar_xpath('//*[@id="select2-location_select_transformer-container"]/span')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Não')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
else:
self.esperar_xpath('//*[@id="select2-location_select_transformer-container"]/span')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Sim')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
self.esperar_xpath('//*[@id="select2-location_select_landed-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Sim')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
#historico
self.esperar_xpath('//*[@id="location_tab_logs"]')
#Origem
if origem:
self.esperar_xpath('//*[@id="select2-location_select_source-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Arquivo Eletrônico')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
elif origem_rs:
self.esperar_xpath('//*[@id="select2-location_select_source-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Geoplex')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
#não possui
time.sleep(1)
self.esperar_clicar_xpath('//*[@id="location_input_hasNoId"]')
time.sleep(2)
#disponibilização
self.esperar_xpath('//*[@id="select2-location_select_provision-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Duplicação Manual')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
else:
self.esperar_xpath('//*[@id="select2-location_select_source-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Netwin')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
#caracteristica
self.esperar_xpath('//*[@id="location_tab_caracterizacao"]')
#proprietario
if proprietario:
self.esperar_xpath('//*[@id="select2-location_select_owner-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Alugado de terceiros')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
else:
self.esperar_xpath('//*[@id="select2-location_select_owner-container"]')
self.driver.find_element(By.XPATH,'//input[@class="select2-search__field"]').send_keys('Oi')
self.driver.find_element(By.XPATH,'//li[@class="select2-results__option select2-results__option--highlighted"]').click()
#etiqueta de campo
if cap == None:
pass
else:
if cap == '':
fornecedor = poste