-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppStoreHuawei.py
More file actions
1107 lines (887 loc) · 41.3 KB
/
Copy pathAppStoreHuawei.py
File metadata and controls
1107 lines (887 loc) · 41.3 KB
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
# 导入selenium的浏览器驱动接口
import sys
import os
import json
o_path = os.getcwd() # 返回当前工作目录
sys.path.append(o_path) # 添加自己指定的搜索路径
from AppStore.AppStoreBase import AppStoreBase
sys.path.append('../../')
sys.path.append('./')
from Common.WebDriver.WebDriverCmd import CmdType
from Common.WebDriver.WebDriverCmd import WebDriverCmd
from Common.WebDriver.WebDriverCmd import CmdInfo
import pyperclip
from Common.Platform import Platform
from Project.Resource import mainResource
from Common import Source
from Common.File.FileUtil import FileUtil
from Common.File.FileBrowser import FileBrowser
from AppInfo.AppInfo import mainAppInfo
from AppStore.Huawei.HuaweiAppGalleryApi import mainHuaweiAppGalleryApi
from AppStore.AppStoreAcount import mainAppStoreAcount
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
import time
import sqlite3
# 要想调用键盘按键操作需要引入keys包
# 导入chrome选项
# pip3 install pywin32
# sys.path.append('../common')
class AppStoreHuawei(AppStoreBase):
defaultLanguage = "美式英语"
fileCookie = "e:/cookies/cookies_huawei.json"
listCountry = ["zh-CN","en-US", "en-GB"]
listCountryLanguage = ["cn","en", "en"]
# listCountry = ["en-AU","en-GB"]
# listCountryLanguage = ["en","en"]
listDisplay = ["APP_PHONE"]
listDisplayName = ["1080p"]
def GoHome(self, isHD):
# self.AddCookie(self.fileCookie)
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
url = "https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/myApp"
print(url)
self.driver.get(url)
self.urlold = self.driver.current_url
time.sleep(3)
def Login(self, user, password):
webcmd = WebDriverCmd(self.driver)
# 3452644866
mainAppInfo.SetSmsCode("")
# 等待扫码登录
# while True:
# time.sleep(1)
# self.urlnew = self.driver.current_url
# if self.urlnew != self.urlold:
# break
# print("waiting for login self.urlnew=",self.urlnew)
# return
# driver.add_cookie("[{'domain': '.id1.cloud.huawei.com', 'expiry': 1908869785, 'httpOnly': False, 'name': 'sid', 'path': '/', 'secure': True, 'value': '2049382e3828ef4470bef8b426c4bb3370e7d9e1147f53a18839e47dad7caf10a233e61ee15337b4373e'}, {'domain': '.id1.cloud.huawei.com', 'expiry': 1908869785, 'httpOnly': False, 'name': 'hwid_cas_sid', 'path': '/', 'secure': True, 'value': '2049382e3828ef4470bef8b426c4bb3370e7d9e1147f53a18839e47dad7caf10a233e61ee15337b4373e'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1624872984, 'httpOnly': False, 'name': 'HW_idts_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': '1593336984125'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1624872984, 'httpOnly': False, 'name': 'HW_id_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': 'cf787be41ac24d65887dcd20c826ac97'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1624872984, 'httpOnly': False, 'name': 'HW_idvc_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': '1'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1593338788, 'httpOnly': False, 'name': 'HW_idn_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': 'ec569450f0ac4cd78fc72965d91ec7e8'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1608888984, 'httpOnly': False, 'name': 'HW_refts_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': '1593336984124'}, {'domain': '.id1.cloud.huawei.com', 'httpOnly': True, 'name': 'CAS_THEME_NAME', 'path': '/', 'secure': True, 'value': 'red'}, {'domain': 'id1.cloud.huawei.com', 'httpOnly': False, 'name': 'cookieBannerOnOff', 'path': '/', 'secure': False, 'value': 'true'}, {'domain': '.id1.cloud.huawei.com', 'httpOnly': True, 'name': 'VERSION_NO', 'path': '/', 'secure': True, 'value': 'UP_CAS_4.0.4.100'}, {'domain': 'id1.cloud.huawei.com', 'httpOnly': True, 'name': 'JSESSIONID', 'path': '/CAS', 'secure': True, 'value': '144E8B2ED3F5D9C8576742C1DDF4CF3D0DCF6949E13D6943'}]")
self.urlold = self.driver.current_url
item = self.driver.find_element(
By.XPATH, "//input[@ht='input_pwdlogin_account']")
item.send_keys(user)
item = self.driver.find_element(By.XPATH, "//input[@ht='input_pwdlogin_pwd']")
item.send_keys(password)
item = self.driver.find_element(
By.XPATH, "//div[@ht='click_pwdlogin_submitLogin']")
item.click()
time.sleep(1)
# 获取验证码
key = "//div[@ht='click_authentication_getAuthcode']"
item = webcmd.Find(key,True)
if item is not None:
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
code = self.GetSmsCode()
print("Login GetSmsCode=",code)
# 输入短信验证码
item = self.driver.find_element(
By.XPATH, "//input[@ht='input_authentication_authcode']")
item.send_keys(code)
# 确定
# key = "//div[@ht='click_dialog_rightbtn']"
key = "//div[@class='dialog-btn btn-next']"
item = webcmd.Find(key,True)
if item is not None:
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
# key = ".//span[text()='确定']"
# key = "//div[@class='dialog-btn btn-next']"
# subitem = webcmd.FindChild(item,key,True)
# print("Click 确定=")
# webcmd.DoCmd(subitem,CmdType.CLICK_Action)
# 信任
key = "//div[@ht='click_dialog_rightbtn']"
item = webcmd.Find(key,True)
# if item is not None:
# key = ".//span[text()='信任']"
# subitem = webcmd.FindChild(item,key,True)
# webcmd.DoCmd(subitem,CmdType.CLICK)
while True:
time.sleep(1)
self.urlnew = self.driver.current_url
if self.urlnew != self.urlold:
break
print("waiting for login self.urlnew=",self.urlnew)
return
# cookie = self.driver.get_cookies()
# print(cookie)
# [{'domain': '.id1.cloud.huawei.com', 'expiry': 1908869785, 'httpOnly': False, 'name': 'sid', 'path': '/', 'secure': True, 'value': '2049382e3828ef4470bef8b426c4bb3370e7d9e1147f53a18839e47dad7caf10a233e61ee15337b4373e'}, {'domain': '.id1.cloud.huawei.com', 'expiry': 1908869785, 'httpOnly': False, 'name': 'hwid_cas_sid', 'path': '/', 'secure': True, 'value': '2049382e3828ef4470bef8b426c4bb3370e7d9e1147f53a18839e47dad7caf10a233e61ee15337b4373e'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1624872984, 'httpOnly': False, 'name': 'HW_idts_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': '1593336984125'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1624872984, 'httpOnly': False, 'name': 'HW_id_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': 'cf787be41ac24d65887dcd20c826ac97'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1624872984, 'httpOnly': False, 'name': 'HW_idvc_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': '1'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1593338788, 'httpOnly': False, 'name': 'HW_idn_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': 'ec569450f0ac4cd78fc72965d91ec7e8'}, {'domain': 'id1.cloud.huawei.com', 'expiry': 1608888984, 'httpOnly': False, 'name': 'HW_refts_id1_cloud_huawei_com_id1_cloud_huawei_com', 'path': '/', 'secure': False, 'value': '1593336984124'}, {'domain': '.id1.cloud.huawei.com', 'httpOnly': True, 'name': 'CAS_THEME_NAME', 'path': '/', 'secure': True, 'value': 'red'}, {'domain': 'id1.cloud.huawei.com', 'httpOnly': False, 'name': 'cookieBannerOnOff', 'path': '/', 'secure': False, 'value': 'true'}, {'domain': '.id1.cloud.huawei.com', 'httpOnly': True, 'name': 'VERSION_NO', 'path': '/', 'secure': True, 'value': 'UP_CAS_4.0.4.100'}, {'domain': 'id1.cloud.huawei.com', 'httpOnly': True, 'name': 'JSESSIONID', 'path': '/CAS', 'secure': True, 'value': '144E8B2ED3F5D9C8576742C1DDF4CF3D0DCF6949E13D6943'}]
# 3452644866 qq31415926
def ShowWebHome(self):
url = "https://developer.huawei.com/consumer"
self.driver.get(url)
time.sleep(2)
def CreateApp(self, isHD):
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
print("CreateApp appid=",appid," isHD=",isHD)
if appid != "0":
self.UpdateAppInfo(isHD)
self.UploadScreenShot(isHD)
self.UpdateApkApi(isHD)
return
# self.Init()
# self.GoHome(isHD)
# self.Login("chyfemail163@163.com", "Qianlizhiwai1")
# self.SaveCookie(self.fileCookie)
webcmd = WebDriverCmd(self.driver)
old_window = self.driver.current_window_handle
url = "https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/myApp"
self.driver.get(url)
time.sleep(2)
title = self.GetAppName(isHD, Source.LANGUAGE_CN,Source.HUAWEI)
print("title =",title)
# 等待网页加载成功
key = "//iframe[@id='mainIframeView']"
while True:
time.sleep(1)
print("web is loading...")
if self.IsElementExist(key) == True:
print("web loading finish")
break
# 跳转到新的页面
print("self.driver.current_url=", self.driver.current_url)
# self.driver.switch_to.window(self.driver.window_handles[0])
for win in self.driver.window_handles:
if win != old_window:
self.driver.switch_to.window(win)
time.sleep(1)
print("self.driver.current_url 2=", self.driver.current_url)
# self.driver.switch_to.frame("mainIframeView")
# time.sleep(1)
self.Switch2MainFrameView()
webcmd.AddCmdWait(CmdType.CLICK, "//button[@id='MyAppListNewApp']")
webcmd.Run(True)
# 请选择应用名称,或填写新应用名称(限64字符)
print("title= ",title)
# try:
# webcmd.AddCmd(CmdType.INPUT, "//input[contains(@placeholder,'请选择应用名称')]", title, 1)
# webcmd.Run(True)
# except Exception as e:
# print("INPUT eror=",e)
key = "//input[contains(@id='PubProAppSortCombo')]"
webcmd.AddCmd(CmdType.CLICK, key)
# <div class="ucd-droplist-option ng-binding ng-scope" ng-bind="parentType.value">应用</div>
key = "//span[text()='应用']"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
# key = "//span[contains(text(),'请选择语言')]"
key = "//input[contains(@id='PubProDefaultLanguagetCombo')]"
webcmd.AddCmd(CmdType.CLICK, key)
key = "//span[text()='" +self.defaultLanguage+"']"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
old_window = self.driver.current_window_handle
# waiting 确定
print("waiting 确定 手动点击 ")
while True:
time.sleep(1)
if self.IsElementExist("//a[@id='PubProDetermine']") == False:
break
print("self.driver.current_url=", self.driver.current_url)
# self.driver.switch_to.window(self.driver.window_handles[0])
for win in self.driver.window_handles:
if win != old_window:
self.driver.switch_to.window(win)
time.sleep(1)
# self.driver.switch_to.frame("mainIframeView")
self.Switch2MainFrameView()
item = webcmd.Find("//span[@id='AppInfoAppIdContent']",True)
appid = item.text
print(appid)
mainAppInfo.SetAppId(isHD, Source.ANDROID, Source.HUAWEI, appid)
# self.FillAppInfo(isHD)
def AddLanguage(self, webcmd, title):
item = webcmd.AddCmdWait(
CmdType.CLICK, "//a[@id='AppInfoManageLanguageButton']")
# self.SetItemVisible(item)
webcmd.Run(True)
webcmd.AddCmd(
CmdType.INPUT, "//input[@ng-model='searchTxt']", title, 2)
webcmd.Run(True)
key = "//span[@title='"+title+"']"
print(key)
if self.IsElementExist(key):
# webcmd.AddCmd2(CmdType.CLICK, key)
webcmd.AddCmd2(
CmdType.CLICK, "//label[@class='checkbox lang-item ng-scope']")
else:
print(key, "is not exit")
# webcmd.AddCmd2(CmdType.CLICK, "//label[@class='checkbox lang-item ng-scope']")
webcmd.Run(True)
item = webcmd.AddCmd2(
CmdType.CLICK, "//a[@class='btn btn-primary btn-small ng-binding']")
# self.SetItemVisible(item)
webcmd.Run(True)
time.sleep(2)
def FillLanguage(self, webcmd, isHD, lanName, lanKey):
# 选择语言
# webcmd.AddCmd(CmdType.CLICK, "//input[@type='search' and @aria-owns='ui-select-choices-3']", "", 1)
item = webcmd.AddCmd(
CmdType.CLICK, "//span[@class='ui-select-match-text pull-left']", "", 2)
self.SetItemVisible(item)
webcmd.Run(True)
# 简体中文-默认
if lanName == self.defaultLanguage:
lanName = lanName+"-默认"
key = "//div[@class='ucd-droplist-option ng-binding' and text()='" + \
lanName+"']"
# key = "//div[@class='ucd-droplist-option ng-binding' and text()='"+lanName+"-默认"+"']"
# if self.IsElementExist(key)==False:
# key = "//div[@class='ucd-droplist-option ng-binding' and text()='"+lanName+"']"
# 模糊匹配
# key = "//div[@class='ucd-droplist-option ng-binding' and contains(text(),'"+lanName+"')]"
item = webcmd.AddCmd(CmdType.CLICK, key, "", 1)
if item == None:
print(key)
else:
self.SetItemVisible(item)
webcmd.Run(True)
title = self.GetAppName(isHD, lanKey,Source.HUAWEI)
print(title)
pyperclip.copy(title)
key = "//input[@id='AppInfoAppNameInputBox']"
webcmd.AddCmd2(CmdType.INPUT_CLEAR, key)
# webcmd.AddCmd(CmdType.ENTER, "//input[@id='AppInfoAppNameInputBox']",title,1)
pyperclip.paste()
webcmd.AddCmd2(CmdType.CTR_V, key)
webcmd.Run(True)
title = self.GetAppDetail(isHD, lanKey)
pyperclip.copy(title)
key = "//textarea[@id='AppInfoAppIntroduceInputBox']"
# webcmd.AddCmd(CmdType.CLICK, key,title,1)
pyperclip.paste()
webcmd.AddCmd2(CmdType.INPUT_CLEAR, key)
webcmd.AddCmd2(CmdType.CTR_V, key)
# webcmd.AddCmd(CmdType.INPUT, "//textarea[@id='AppInfoAppIntroduceInputBox']",title,2)
webcmd.Run(True)
time.sleep(2)
title = self.GetAppPromotion(isHD, lanKey)
print(title)
pyperclip.copy(title)
key = "//input[@id='AppInfoAppBriefInputBox']"
item = self.driver.find_element(By.XPATH, key)
ActionChains(self.driver).move_to_element(item).perform()
time.sleep(1)
# webcmd.AddCmd(CmdType.ENTER, "//input[@id='AppInfoAppBriefInputBox']",title,1)
pyperclip.paste()
# webcmd.AddCmd2(CmdType.INPUT_CLEAR, key)
webcmd.AddCmd2(CmdType.CLICK, key)
webcmd.AddCmd2(CmdType.INPUT_CLEAR, key)
# 必须enter选中
webcmd.AddCmd2(CmdType.ENTER, key)
webcmd.AddCmd2(CmdType.CTR_V, key)
webcmd.Run(True)
time.sleep(2)
# icon
key = "//img[@id='AppInfoAppIconAddButton']"
item = self.driver.find_element(By.XPATH, key)
ActionChains(self.driver).move_to_element(item).perform()
time.sleep(2)
# webcmd.AddCmd2(CmdType.ENTER, key)
# webcmd.AddCmd(CmdType.CLICK, key, "", 2)
item.click()
icon = mainResource.GetOutPutIconPathWin32(mainResource.GetProjectOutPut(
), Source.TAPTAP, isHD)+"\\huawei\\icon_android_216.png"
print(icon)
# webcmd.Run(True)
time.sleep(2)
self.OpenFileBrowser(icon, True)
time.sleep(2)
# <span class="text ng-binding">横向截图</span>
idx_start = 6
strkey = "竖向截图"
if isHD:
idx_start = 1
strkey = "横向截图"
key = "//span[@class='text ng-binding' and text()='"+strkey+"']"
item = webcmd.AddCmd(CmdType.CLICK, key)
self.SetItemVisible(item)
webcmd.Run(True)
for i in range(0, 5):
key = "//img[@id='AppIntroScreenshot"+str(i+idx_start)+"']"
item = self.driver.find_element(By.XPATH, key)
if i >= 2:
# 将 滚动条 底部对齐
self.driver.execute_script(
"arguments[0].scrollIntoView(false);", item)
time.sleep(2)
# 鼠标悬停
ActionChains(self.driver).move_to_element(item).perform()
time.sleep(2)
# webcmd.AddCmd(CmdType.CLICK, key, "", 2)
item.click()
time.sleep(2)
# webcmd.AddCmd2(CmdType.ENTER, key)
pic = mainResource.GetOutPutScreenshotPathWin32(mainResource.GetProjectOutPut(
), Source.TAPTAP, isHD) + "\\"+lanKey+"\\1080p\\"+str(i+1)+".jpg"
print(pic)
# webcmd.Run(True)
self.OpenFileBrowser(pic, True)
time.sleep(2)
def Switch2MainFrameView(self):
webcmd = WebDriverCmd(self.driver)
# 等待网页加载成功
key = "//iframe[@id='mainIframeView']"
while True:
time.sleep(1)
print("web is Switch2MainFrameView...")
if self.IsElementExist(key) == True:
print("web Switch2MainFrameView finish")
break
self.driver.switch_to.frame("mainIframeView")
time.sleep(2)
def FillAppInfo(self, isHD):
webcmd = WebDriverCmd(self.driver)
old_window = self.driver.current_window_handle
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
url = "https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/myApp/"+appid
print(url)
self.driver.get(url)
time.sleep(3)
# 跳转到新的页面
print("self.driver.current_url=", self.driver.current_url)
# self.driver.switch_to.window(self.driver.window_handles[0])
for win in self.driver.window_handles:
if win != old_window:
self.driver.switch_to.window(win)
time.sleep(1)
print("self.driver.current_url 2=", self.driver.current_url)
# 等待网页加载成功
# key = "//iframe[@id='mainIframeView']"
# while True:
# time.sleep(1)
# print("web is loading...")
# if self.IsElementExist(key) == True:
# print("web loading finish")
# break
# self.driver.switch_to.frame("mainIframeView")
# time.sleep(2)
self.Switch2MainFrameView()
# 填写语言资料
lanKeys = ("简体中文", "英式英语", "美式英语")
applans = (Source.LANGUAGE_CN, Source.LANGUAGE_EN, Source.LANGUAGE_EN)
# 添加语言
for lan in range(0, len(lanKeys)):
self.AddLanguage(webcmd, lanKeys[lan])
# 填写语言
for lan in range(0, len(lanKeys)):
self.FillLanguage(webcmd, isHD, lanKeys[lan], applans[lan])
# 滚动到浏览器顶部
js_top = "var q=document.documentElement.scrollTop=0"
# 滚动到浏览器底部
js_bottom = "var q=document.documentElement.scrollTop=document.documentElement.scrollHeight"
self.driver.execute_script(js_bottom)
time.sleep(2)
# 应用分类
isSort = True
# 请选择二级分类
key = "//span[contains(text(),'请选择二级分类')]"
isSort = self.IsElementExist(key)
if isSort == False:
print("not find key="+key)
isSort = False
# return
if isSort:
item = webcmd.AddCmd(CmdType.CLICK, key)
self.SetItemVisible(item)
webcmd.Run(True)
# <div class="ucd-droplist-option ng-binding">教育</div>
key = "//div[@class='ucd-droplist-option ng-binding' and contains(text(),'教育')]"
item = webcmd.AddCmd(CmdType.CLICK, key)
self.SetItemVisible(item)
webcmd.Run(True)
key = "//span[contains(text(),'请选择三级分类')]"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
# <div class="ucd-droplist-option ng-binding">学习</div>
key = "//div[@class='ucd-droplist-option ng-binding' and contains(text(),'学习')]"
item = webcmd.AddCmd(CmdType.CLICK, key)
self.SetItemVisible(item)
webcmd.Run(True)
key = "//input[@id='AppInfoCustomerEmailInputBox']"
item = webcmd.AddCmd(CmdType.INPUT, key, "chyfemail163@163.com")
self.SetItemVisible(item)
webcmd.Run(True)
# 保存
key = "//a[@id='AppInfoSaveButtonCn']"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
time.sleep(3)
# 确定
key = "//a[@id='CommonConfirmButtonOk']"
if self.IsElementExist(key):
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
self.PreSubmitApp(isHD)
else:
self.PreSubmitApp(isHD)
def GetPrivacy(self, isHD):
return mainAppStoreAcount.GetPrivacy(Source.HUAWEI,mainAppInfo.GetAppStoreAcount(isHD,Source.HUAWEI))
# 准备提交app
def PreSubmitApp(self, isHD):
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
url = "https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/myApp/"+appid
print(url)
self.driver.get(url)
time.sleep(3)
old_window = self.driver.current_window_handle
webcmd = WebDriverCmd(self.driver)
# 准备提交
key = "//span[@class='yellow-circle']"
webcmd.AddCmdWait(CmdType.CLICK, key)
webcmd.Run(True)
# 跳转到新的页面
print("self.driver.current_url=", self.driver.current_url)
# self.driver.switch_to.window(self.driver.window_handles[0])
for win in self.driver.window_handles:
if win != old_window:
self.driver.switch_to.window(win)
time.sleep(1)
print("self.driver.current_url 2=", self.driver.current_url)
# 等待网页加载成功
# key = "//iframe[@id='mainIframeView']"
# while True:
# time.sleep(1)
# print("web is loading...")
# if self.IsElementExist(key) == True:
# print("web loading finish")
# break
# self.driver.switch_to.frame("mainIframeView")
# time.sleep(3)
self.Switch2MainFrameView()
# # 管理国家
# key = "//a[@id='VerInfoManageCountryButton']"
# webcmd.AddCmd(CmdType.CLICK, key)
# webcmd.Run(True)
# # 全球
# key = "//span[@id='CountryCheckMarkGlobal']"
# webcmd.AddCmd(CmdType.CLICK, key)
# webcmd.Run(True)
# self.UpdateApk(isHD)
# 分级
# key = "//a[@class='agc-button-primary agc-button-normal version-info-rate ml-0 ng-binding' and contains(text(),'分级')]"
key = "//a[contains(text(),'分级')]"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
time.sleep(3)
# 分级勾选
key = "//div[@class='rate-dialog-content']"
# div = self.driver.find_element(By.XPATH, key)
key = "//label[@class='radio rate-dialog-huaweiRating']"
webcmd.AddCmd(CmdType.CLICK, key)
# 分级确认
key = "//a[@id='submit']"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
# copyright
key = "//img[@id='AppInfoUploadCertificateURLs1']"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
apk = mainResource.GetOutPutCopyRightPathWin32(
mainResource.GetProjectOutPut(), isHD)+"\\huawei.png"
print(apk)
flag = os.path.exists(apk)
if flag:
self.OpenFileBrowser(apk, True)
time.sleep(2)
# 隐私政策网址
key = "//input[@id='VerInfoPrivacyPolicyInputBox']"
webcmd.AddCmd(CmdType.INPUT, key, self.GetPrivacy(isHD))
webcmd.Run(True)
# <span class="text ng-binding">审核通过立即上架</span>
key = "//span[@class='text ng-binding' and contains(text(),'审核通过立即上架')]"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
# 保存
key = "//a[@id='VerInfoSaveButton']"
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
time.sleep(2)
# 确定 保存
# <a class="btn btn-primary btn-small ng-binding" data-dismiss="dialog" ng-click="callback()">确定</a>
key = "//a[@class='btn btn-primary btn-small ng-binding' and contains(text(),'确定')]"
if self.IsElementExist(key):
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
self.UpdateApk(isHD)
self.SubmitApp(isHD)
def SearchApp(self, ishd):
name = self.GetAppName(ishd, Source.LANGUAGE_CN,Source.HUAWEI)
item = self.driver.find_element(
By.XPATH, "//input[@ng-model='Model.product.query.appName']")
item.send_keys(name)
time.sleep(1)
# search
self.driver.find_element_by_id('search_medium_id').click()
time.sleep(2)
def SubmitApp(self, isHD):
webcmd = WebDriverCmd(self.driver)
# 隐私政策网址
key = "//input[@id='VerInfoPrivacyPolicyInputBox']"
if self.IsElementExist(key):
webcmd.AddCmd(CmdType.INPUT, key, self.GetPrivacy(isHD))
webcmd.Run(True)
# 不申请
key = "//span[@id='VerInfoNotApplyButton']"
if self.IsElementExist(key):
webcmd.AddCmd(CmdType.CLICK_Action, key)
webcmd.Run(True)
# item = self.driver.find_element(By.XPATH, "//span[@id='VerInfoNotApplyButton']")
# item.click()
# time.sleep(1)
# 提交审核
key = "//a[@id='VerInfoSubmitButton']"
if self.IsElementExist(key):
webcmd.AddCmd(CmdType.CLICK_Action, key)
webcmd.Run(True)
time.sleep(3)
# 确定
key = "//a[@id='AppSubmitConfirmButtonOk']"
if self.IsElementExist(key):
webcmd.AddCmd(CmdType.CLICK_Action, key)
webcmd.Run(True)
time.sleep(3)
def UpdateApk(self, isHD):
webcmd = WebDriverCmd(self.driver)
# 滚动到浏览器顶部
js_top = "var q=document.documentElement.scrollTop=0"
# 滚动到浏览器底部
js_bottom = "var q=document.documentElement.scrollTop=document.documentElement.scrollHeight"
self.driver.execute_script(js_top)
time.sleep(2)
# key = "//iframe[@id='mainIframeView']"
# if self.IsElementExist(key)==True:
# self.driver.switch_to.frame("mainIframeView")
# time.sleep(1)
# 软件包管理
# time.sleep(1)
# info = CmdInfo()
# info.type = CmdType.CLICK_SCRIPT
# info.cmd = "//a[@id='VerInfoDownloadLink']"
# info.value = ""
# info.delay = 1
# info.isWaiting = True
# item = webcmd.AddCmdInfo(info)
# self.SetItemVisible(item)
key = "//a[@id='VerInfoDownloadLink']"
item = webcmd.Find(key,True)
self.SetItemVisible(item)
webcmd.AddCmdWait(CmdType.CLICK_Action, key)
webcmd.Run(True)
webcmd.AddCmd(CmdType.CLICK_SCRIPT,
"//a[@id='ManageAppUploadPackageButton']")
webcmd.Run(True)
# <a class="agc-button-primary agc-button-normal ng-binding" ng-click="uploadPkg()" ng-show="!notAllowedUploadPkg" target="_blank">上传</a>
# 第一次上传
key = "//a[@ng-show='!notAllowedUploadPkg' and contains(text(),'上传')]"
if self.IsElementExist(key):
webcmd.AddCmd(CmdType.CLICK_SCRIPT, key)
webcmd.Run(True)
webcmd.AddCmd(CmdType.CLICK_Action,
"//div[@id='uploaderSelectContainer']")
webcmd.Run(True)
time.sleep(2)
apk = mainResource.GetOutPutApkPathWin32(
mainResource.GetProjectOutPut(), Source.HUAWEI, isHD)
print(apk)
self.OpenFileBrowser(apk, True)
time.sleep(1)
# <div class="uploader-progress-bar" ng-style="{width: uploadProgress}"></div>
# # <div class="progress"><div class="progress-bar" style="width: 82%;" aria-valuenow="82"></div></div>
# 等待上传完成
isUploading = False
while True:
time.sleep(1)
key = "//div[@class='uploader-progress-bar']"
if self.IsElementExist(key):
item = self.driver.find_element(By.XPATH, key)
if item is not None:
style = item.get_attribute('style')
isUploading = True
print(style)
# if style.find("100") >=0:
# time.sleep(1)
# print("upload apk finish")
# break
else:
if isUploading == True:
isUploading = False
time.sleep(1)
print("upload apk finish")
break
time.sleep(1)
# 不申请
# webcmd.AddCmd(CmdType.CLICK, "//span[@id='VerInfoNotApplyButton']")
# webcmd.Run(True)
# 提交审核
# webcmd.AddCmd(CmdType.CLICK, "//a[@id='VerInfoSubmitButton']")
# webcmd.Run(True)
# time.sleep(3)
# 确定
# webcmd.AddCmd(CmdType.CLICK, "//a[@id='AppSubmitConfirmButtonOk']")
# webcmd.Run(True)
# time.sleep(3)
def UpdateApp(self, isHD):
# self.UpdateAppOld(isHD)
# return
old_window = self.driver.current_window_handle
webcmd = WebDriverCmd(self.driver)
# 打开新标签
# self.driver.find_element_by_xpath('//body').send_keys(Keys.CONTROL,"t")
# js = "window.open('')"
# self.driver.execute_script(js)
# time.sleep(2)
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
# https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/myApp/101054959
url = "https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/myApp/"+appid
self.driver.get(url)
time.sleep(1)
# 等待网页加载成功
# key = "//iframe[@id='mainIframeView']"
# while True:
# time.sleep(1)
# print("web is loading...")
# if self.IsElementExist(key) == True:
# print("web loading finish")
# break
# self.driver.switch_to.frame("mainIframeView")
# time.sleep(3)
self.Switch2MainFrameView()
key = "//span[@title='版本信息']"
if self.IsElementExist(key) == False:
print("find 版本信息 fail key=",key)
self.UpdateApp(isHD)
key = "//span[@class='green-circle']"
# red-circle
if self.IsElementExist(key) == False:
print("key fail key=",key)
# 待修改
key = "//span[@class='red-circle']"
if self.IsElementExist(key) == False:
key = "//span[@class='yellow-circle']"
# 第一次上传apk
# self.PreSubmitApp(isHD)
# return
if self.IsElementExist(key) == False:
print("key fail key2=",key)
print("self.driver.current_url fail=", self.driver.current_url)
# print(self.driver.page_source)
mainResource.saveString2File(self.driver.page_source,"1.html")
webcmd.AddCmd(CmdType.CLICK, key)
webcmd.Run(True)
time.sleep(5)
# 跳转到新的页面
print("self.driver.current_url=", self.driver.current_url)
# self.driver.switch_to.window(self.driver.window_handles[0])
for win in self.driver.window_handles:
if win != old_window:
self.driver.switch_to.window(win)
time.sleep(3)
print("self.driver.current_url 2=", self.driver.current_url)
# self.driver.switch_to.frame("mainIframeView")
self.Switch2MainFrameView()
old_window = self.driver.current_window_handle
# 升级按钮
key = "//a[@id='VersionUpgradeButton']"
if self.IsElementExist(key):
webcmd.AddCmd(CmdType.CLICK_Action, key)
webcmd.Run(True)
time.sleep(2)
# 跳转到新的页面
print("self.driver.current_url=", self.driver.current_url)
# self.driver.switch_to.window(self.driver.window_handles[0])
for win in self.driver.window_handles:
if win != old_window:
self.driver.switch_to.window(win)
time.sleep(3)
print("self.driver.current_url 2=", self.driver.current_url)
# self.driver.switch_to.frame("mainIframeView")
# time.sleep(3)
self.Switch2MainFrameView()
self.UpdateApk(isHD)
time.sleep(1)
self.SubmitApp(isHD)
def SearchApp(self, ishd):
name = self.GetAppName(ishd, Source.LANGUAGE_CN,Source.HUAWEI)
self.driver.get("https://adnet.qq.com/medium/list")
time.sleep(2)
item = self.driver.find_element(
By.XPATH, "//input[@class='form-control']")
time.sleep(1)
item.send_keys(name)
# item.send_keys("儿童写汉字")
time.sleep(1)
# search
self.driver.find_element_by_id('search_medium_id').click()
time.sleep(2)
# 筛选
item = self.driver.find_element(
By.XPATH, "//button[@class='btn filter-operate']")
# item = self.driver.find_element(By.XPATH, "//div[@class='filter-parent-control']")
# error
# item.click()
self.driver.execute_script("arguments[0].click();", item)
time.sleep(2)
# <input type="checkbox" class="check" name="" value="IOS">
if self.osApp == Source.ANDROID:
item = self.driver.find_element(
By.XPATH, "//input[@value='Android']")
# item.click()
self.driver.execute_script("arguments[0].click();", item)
time.sleep(1)
if self.osApp == Source.IOS:
item = self.driver.find_element(By.XPATH, "//input[@value='IOS']")
# item.click()
self.driver.execute_script("arguments[0].click();", item)
time.sleep(1)
# 确定
item = self.driver.find_element(
By.XPATH, "//button[@class='btn btn-primary']")
# item.click()
self.driver.execute_script("arguments[0].click();", item)
time.sleep(2)
# 点击第一个
item = self.driver.find_element(By.XPATH, "//div[@class='media']")
item.click()
time.sleep(1)
def UpdateApkApi(self,isHD):
package = mainAppInfo.GetAppPackage(Source.ANDROID,isHD,Source.HUAWEI)
apk = mainResource.GetOutPutApkPath(Source.HUAWEI, isHD)
if not os.path.exists(apk):
apk = mainResource.GetOutPutApkPath(Source.TAPTAP, isHD)
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
mainHuaweiAppGalleryApi.UploadApk(appid,apk)
def DeleteAllLanguage(self, isHD):
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
for country in self.listCountry:
mainHuaweiAppGalleryApi.DeleteLanuage(appid,country)
def UpdateAppInfo(self, isHD):
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
defaultLang = "en-US"
policyUrl= self.GetPrivacy(isHD)
mainHuaweiAppGalleryApi.UpdateAppBaseInfo(appid,defaultLang,policyUrl)
idx = 0
for country in self.listCountry:
lan = self.listCountryLanguage[idx]
title= mainAppInfo.GetAppName(Source.ANDROID, isHD,lan,Source.HUAWEI)
detail = mainAppInfo.GetAppDetail(isHD,lan)
shortDetail = mainAppInfo.GetAppPromotion(isHD,lan)
whatsNew = mainAppInfo.GetAppUpdate(isHD,lan)
mainHuaweiAppGalleryApi.UpdateAppInfo(appid,country,title,detail,shortDetail,whatsNew)
# subtitle= mainAppInfo.GetAppSubtitle(isHD,lan)
#
# policyText =""
# keywords = mainAppInfo.GetAso(isHD,Source.APPSTORE,lan)
# marketingUrl = mainAppInfo.GetAppSoftwareurl(isHD)
# promotionalText = mainAppInfo.GetAppPromotion(isHD, lan)
# supportUrl = mainAppInfo.GetAppSupporturl(isHD)
idx+=1
def GetImageScreenShot(self, isHD,lan,idx):
pic_name = mainResource.GetOutPutScreenshotPathWin32(mainResource.GetProjectOutPut(), Source.TAPTAP, isHD) + "\\"+lan+"\\1080p\\"+str(idx+1)
pic = pic_name+".webp"
if Platform.isMacSystem():
pic = pic.replace("\\","/")
if not os.path.exists(pic):
pic = pic_name+".jpg"
return pic
def GetCopyRight(self, isHD):
pic = mainResource.GetOutPutCopyRightPathWin32(mainResource.GetProjectOutPut(), isHD)+"\\huawei.png"
if not os.path.exists(pic):
pic = mainResource.GetOutPutCopyRightPathWin32(mainResource.GetProjectOutPut(), isHD)+"\\Huawei.png"
if Platform.isMacSystem():
pic = pic.replace("\\","/")
return pic
def UploadScreenShot(self, isHD):
appid = mainAppInfo.GetAppId(isHD, Source.HUAWEI)
# mainHuaweiAppGalleryApi.DeleteLanuage(appid,"zh-CN")
# return
pic = self.GetCopyRight(isHD)
if os.path.exists(pic):
mainHuaweiAppGalleryApi.UploadImageCopyRight(appid,pic)
# return
idx = 0
for country in self.listCountry:
lan = self.listCountryLanguage[idx]
icon = mainResource.GetOutPutIconPathWin32(mainResource.GetProjectOutPut(), Source.TAPTAP, isHD)+"\\huawei\\icon_android_216.png"