fix kktix auto refresh bug
parent
5f9f8eeb5e
commit
9fbc81a90f
|
@ -39,7 +39,7 @@ logger = logging.getLogger('logger')
|
||||||
#附註1:沒有寫的很好,很多地方應該可以模組化。
|
#附註1:沒有寫的很好,很多地方應該可以模組化。
|
||||||
#附註2:
|
#附註2:
|
||||||
|
|
||||||
CONST_APP_VERSION = u"MaxBot (2019.11.22)"
|
CONST_APP_VERSION = u"MaxBot (2019.12.04)"
|
||||||
|
|
||||||
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
|
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
|
||||||
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
|
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
|
||||||
|
@ -1355,34 +1355,64 @@ def kktix_reg_new(url, answer_index):
|
||||||
pass
|
pass
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# check is able to buy.
|
|
||||||
# auto refresh for area list page.
|
# auto refresh for area list page.
|
||||||
is_need_refresh = False
|
is_need_refresh = False
|
||||||
|
|
||||||
|
person_agree_terms_checkbox = None
|
||||||
|
try:
|
||||||
|
person_agree_terms_checkbox = driver.find_element(By.ID, 'person_agree_terms')
|
||||||
|
if person_agree_terms_checkbox is not None:
|
||||||
|
if person_agree_terms_checkbox.is_enabled():
|
||||||
|
#print("find person_agree_terms checkbox")
|
||||||
|
if not person_agree_terms_checkbox.is_selected():
|
||||||
|
#print('send check to checkbox')
|
||||||
|
person_agree_terms_checkbox.click()
|
||||||
|
else:
|
||||||
|
#print('checked')
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
is_need_refresh = True
|
||||||
|
else:
|
||||||
|
is_need_refresh = True
|
||||||
|
print("find person_agree_terms checkbox fail")
|
||||||
|
except Exception as exc:
|
||||||
|
print("find person_agree_terms checkbox Exception")
|
||||||
|
pass
|
||||||
|
print('check agree_terms_checkbox, is_need_refresh:',is_need_refresh)
|
||||||
|
|
||||||
|
# check is able to buy.
|
||||||
registrationsNewApp_div = None
|
registrationsNewApp_div = None
|
||||||
el_list = None
|
el_list = None
|
||||||
|
if not is_need_refresh:
|
||||||
try:
|
try:
|
||||||
registrationsNewApp_div = driver.find_element(By.CSS_SELECTOR, '#registrationsNewApp')
|
registrationsNewApp_div = driver.find_element(By.CSS_SELECTOR, '#registrationsNewApp')
|
||||||
if registrationsNewApp_div is not None:
|
if registrationsNewApp_div is not None:
|
||||||
#print("found registrationsNewApp")
|
#print("found registrationsNewApp")
|
||||||
el_list = registrationsNewApp_div.find_elements(By.TAG_NAME, "input")
|
el_list = registrationsNewApp_div.find_elements(By.CSS_SELECTOR, "input[type='text']")
|
||||||
if el_list is None:
|
if el_list is None:
|
||||||
#print("not found input")
|
#print("query input[type='text'] return None")
|
||||||
is_need_refresh = True
|
is_need_refresh = True
|
||||||
else:
|
else:
|
||||||
#print("found input")
|
#print("found input")
|
||||||
if len(el_list) == 0:
|
if len(el_list) == 0:
|
||||||
|
#print("query input[type='text'] length zero")
|
||||||
is_need_refresh = True
|
is_need_refresh = True
|
||||||
else:
|
else:
|
||||||
is_all_input_hidden = True
|
is_all_input_disable = True
|
||||||
idx = 0
|
idx = 0
|
||||||
for el in el_list:
|
for el in el_list:
|
||||||
idx += 1
|
idx += 1
|
||||||
if el.is_enabled():
|
if el.is_enabled():
|
||||||
# check type
|
is_all_input_disable = False
|
||||||
input_type = el.get_attribute('type')
|
else:
|
||||||
if input_type == "text":
|
# check value
|
||||||
is_all_input_hidden = False
|
input_value = str(el.get_attribute('value'))
|
||||||
if is_all_input_hidden:
|
#print("ticker(%d) number value is:'%s'" % (idx,input_value))
|
||||||
|
if input_value.strip() != '0':
|
||||||
|
#print("found not zero value, do not refresh!")
|
||||||
|
is_all_input_disable = False
|
||||||
|
|
||||||
|
if is_all_input_disable:
|
||||||
#print("found all input hidden")
|
#print("found all input hidden")
|
||||||
is_need_refresh = True
|
is_need_refresh = True
|
||||||
else:
|
else:
|
||||||
|
@ -1394,32 +1424,13 @@ def kktix_reg_new(url, answer_index):
|
||||||
|
|
||||||
if is_need_refresh:
|
if is_need_refresh:
|
||||||
try:
|
try:
|
||||||
# this may cause fail!
|
print("try to refresh page...")
|
||||||
driver.refresh()
|
driver.refresh()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
#print("refresh fail")
|
#print("refresh fail")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
# method #2
|
|
||||||
person_agree_terms_checkbox = None
|
|
||||||
try:
|
|
||||||
person_agree_terms_checkbox = driver.find_element(By.ID, 'person_agree_terms')
|
|
||||||
if person_agree_terms_checkbox is not None:
|
|
||||||
#print("find person_agree_terms checkbox")
|
|
||||||
if not person_agree_terms_checkbox.is_selected():
|
|
||||||
#print('send check to checkbox')
|
|
||||||
person_agree_terms_checkbox.click()
|
|
||||||
else:
|
|
||||||
#print('checked')
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
print("find person_agree_terms checkbox fail")
|
|
||||||
except Exception as exc:
|
|
||||||
print("find person_agree_terms checkbox Exception")
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------
|
#---------------------------
|
||||||
# part 2: ticket number
|
# part 2: ticket number
|
||||||
|
|
|
@ -16,7 +16,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
|
||||||
CONST_APP_VERSION = u"MaxBot (2019.11.22)"
|
CONST_APP_VERSION = u"MaxBot (2019.12.04)"
|
||||||
|
|
||||||
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
|
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
|
||||||
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
|
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
|
||||||
|
|
Loading…
Reference in New Issue