2022-11-09, fix stale element reference: element is not attached to the page document.
parent
24f59119ed
commit
d8056046f2
|
@ -953,7 +953,14 @@ def tixcraft_home(driver):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if accept_all_cookies_btn is not None:
|
if accept_all_cookies_btn is not None:
|
||||||
if accept_all_cookies_btn.is_enabled() and accept_all_cookies_btn.is_displayed():
|
is_visible = False
|
||||||
|
try:
|
||||||
|
if accept_all_cookies_btn.is_enabled() and accept_all_cookies_btn.is_displayed():
|
||||||
|
is_visible = True
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if is_visible:
|
||||||
try:
|
try:
|
||||||
accept_all_cookies_btn.click()
|
accept_all_cookies_btn.click()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
@ -972,7 +979,15 @@ def tixcraft_home(driver):
|
||||||
if close_all_alert_btns is not None:
|
if close_all_alert_btns is not None:
|
||||||
#print('alert count:', len(close_all_alert_btns))
|
#print('alert count:', len(close_all_alert_btns))
|
||||||
for alert_btn in close_all_alert_btns:
|
for alert_btn in close_all_alert_btns:
|
||||||
if alert_btn.is_enabled() and alert_btn.is_displayed():
|
# fix bug: Message: stale element reference: element is not attached to the page document
|
||||||
|
is_visible = False
|
||||||
|
try:
|
||||||
|
if alert_btn.is_enabled() and alert_btn.is_displayed():
|
||||||
|
is_visible = True
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if is_visible:
|
||||||
try:
|
try:
|
||||||
alert_btn.click()
|
alert_btn.click()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
@ -1582,7 +1597,14 @@ def tixcraft_verify(driver, url):
|
||||||
is_submited = False
|
is_submited = False
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
if form_input is not None:
|
if form_input is not None:
|
||||||
if form_input.is_enabled():
|
is_visible = False
|
||||||
|
try:
|
||||||
|
if form_input.is_enabled():
|
||||||
|
is_visible = True
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if is_visible:
|
||||||
try:
|
try:
|
||||||
form_input.click()
|
form_input.click()
|
||||||
is_submited = True
|
is_submited = True
|
||||||
|
@ -1700,7 +1722,14 @@ def kktix_events_press_next_button(driver):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not next_step_button is None:
|
if not next_step_button is None:
|
||||||
if next_step_button.is_enabled():
|
is_visible = False
|
||||||
|
try:
|
||||||
|
if next_step_button.is_enabled():
|
||||||
|
is_visible = True
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if is_visible:
|
||||||
try:
|
try:
|
||||||
driver.execute_script("arguments[0].click();", next_step_button)
|
driver.execute_script("arguments[0].click();", next_step_button)
|
||||||
ret = True
|
ret = True
|
||||||
|
@ -1737,7 +1766,14 @@ def kktix_press_next_button(driver):
|
||||||
#pass
|
#pass
|
||||||
|
|
||||||
if not next_step_button is None:
|
if not next_step_button is None:
|
||||||
if next_step_button.is_enabled():
|
is_visible = False
|
||||||
|
try:
|
||||||
|
if next_step_button.is_enabled():
|
||||||
|
is_visible = True
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if is_visible:
|
||||||
try:
|
try:
|
||||||
driver.execute_script("arguments[0].click();", next_step_button)
|
driver.execute_script("arguments[0].click();", next_step_button)
|
||||||
ret = True
|
ret = True
|
||||||
|
@ -1890,47 +1926,41 @@ def kktix_assign_ticket_number(driver, ticket_number, kktix_area_keyword, kktix_
|
||||||
area = areas[target_row_index]
|
area = areas[target_row_index]
|
||||||
|
|
||||||
if area is not None:
|
if area is not None:
|
||||||
|
#print("area text", area.text)
|
||||||
|
ticket_price_input = None
|
||||||
try:
|
try:
|
||||||
#print("area text", area.text)
|
wait = WebDriverWait(area, 1)
|
||||||
ticket_price_input = None
|
ticket_price_input = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[type='text']")))
|
||||||
try:
|
if ticket_price_input is not None:
|
||||||
wait = WebDriverWait(area, 1)
|
if ticket_price_input.is_enabled():
|
||||||
ticket_price_input = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[type='text']")))
|
current_ticket_number = str(ticket_price_input.get_attribute('value'))
|
||||||
if ticket_price_input is not None:
|
if current_ticket_number == "0":
|
||||||
if ticket_price_input.is_enabled():
|
try:
|
||||||
current_ticket_number = str(ticket_price_input.get_attribute('value'))
|
#print("asssign ticket number:%s" % str(ticket_number))
|
||||||
if current_ticket_number == "0":
|
ticket_price_input.clear()
|
||||||
try:
|
ticket_price_input.send_keys(ticket_number)
|
||||||
#print("asssign ticket number:%s" % str(ticket_number))
|
|
||||||
ticket_price_input.clear()
|
|
||||||
ticket_price_input.send_keys(ticket_number)
|
|
||||||
|
|
||||||
ret = True
|
ret = True
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print("asssign ticket number to ticket-price field Exception:")
|
print("asssign ticket number to ticket-price field Exception:")
|
||||||
print(exc)
|
print(exc)
|
||||||
ticket_price_input.clear()
|
ticket_price_input.clear()
|
||||||
ticket_price_input.send_keys("1")
|
ticket_price_input.send_keys("1")
|
||||||
|
|
||||||
ret = True
|
ret = True
|
||||||
pass
|
pass
|
||||||
else:
|
|
||||||
# assigned
|
|
||||||
if str(ticket_number) == current_ticket_number:
|
|
||||||
ret = True
|
|
||||||
else:
|
else:
|
||||||
print("find input, but not is enabled!")
|
# assigned
|
||||||
|
if str(ticket_number) == current_ticket_number:
|
||||||
|
ret = True
|
||||||
else:
|
else:
|
||||||
print("find input div fail!")
|
print("find input, but not is enabled!")
|
||||||
|
else:
|
||||||
except Exception as exc:
|
print("find input div fail!")
|
||||||
print("find input tag for price Exception")
|
|
||||||
#print(exc)
|
|
||||||
pass
|
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print("auto fill ticket number fail")
|
print("find input tag for price Exception")
|
||||||
print(exc)
|
#print(exc)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -2819,6 +2849,13 @@ def fami_activity(driver, url):
|
||||||
fami_start_to_buy_button = None
|
fami_start_to_buy_button = None
|
||||||
fami_start_to_buy_button = driver.find_element(By.ID, 'buyWaiting')
|
fami_start_to_buy_button = driver.find_element(By.ID, 'buyWaiting')
|
||||||
if fami_start_to_buy_button is not None:
|
if fami_start_to_buy_button is not None:
|
||||||
|
is_visible = False
|
||||||
|
try:
|
||||||
|
if fami_start_to_buy_button.is_enabled():
|
||||||
|
is_visible = True
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
if fami_start_to_buy_button.is_enabled():
|
if fami_start_to_buy_button.is_enabled():
|
||||||
try:
|
try:
|
||||||
fami_start_to_buy_button.click()
|
fami_start_to_buy_button.click()
|
||||||
|
@ -2899,7 +2936,14 @@ def fami_home(driver, url):
|
||||||
my_css_selector = "div.col > a.btn"
|
my_css_selector = "div.col > a.btn"
|
||||||
fami_assign_site_button = driver.find_element(By.CSS_SELECTOR, my_css_selector)
|
fami_assign_site_button = driver.find_element(By.CSS_SELECTOR, my_css_selector)
|
||||||
if fami_assign_site_button is not None:
|
if fami_assign_site_button is not None:
|
||||||
if fami_assign_site_button.is_enabled():
|
is_visible = False
|
||||||
|
try:
|
||||||
|
if fami_assign_site_button.is_enabled():
|
||||||
|
is_visible = True
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if is_visible:
|
||||||
try:
|
try:
|
||||||
fami_assign_site_button.click()
|
fami_assign_site_button.click()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
@ -2938,7 +2982,14 @@ def fami_home(driver, url):
|
||||||
|
|
||||||
if area_target is not None:
|
if area_target is not None:
|
||||||
#print("area text", area_target.text)
|
#print("area text", area_target.text)
|
||||||
if area_target.is_enabled():
|
is_visible = False
|
||||||
|
try:
|
||||||
|
if area_target.is_enabled():
|
||||||
|
is_visible = True
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if is_visible:
|
||||||
try:
|
try:
|
||||||
area_target.click()
|
area_target.click()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|
Loading…
Reference in New Issue