2023-02-06, support Edge browser.
parent
d9c2695fc4
commit
c94e31f826
|
@ -389,12 +389,23 @@ def get_driver_by_config(config_dict, driver_type):
|
||||||
|
|
||||||
if browser == "firefox":
|
if browser == "firefox":
|
||||||
# default os is linux/mac
|
# default os is linux/mac
|
||||||
|
# download url: https://github.com/mozilla/geckodriver/releases
|
||||||
chromedriver_path = os.path.join(webdriver_path,"geckodriver")
|
chromedriver_path = os.path.join(webdriver_path,"geckodriver")
|
||||||
if platform.system().lower()=="windows":
|
if platform.system().lower()=="windows":
|
||||||
chromedriver_path = os.path.join(webdriver_path,"geckodriver.exe")
|
chromedriver_path = os.path.join(webdriver_path,"geckodriver.exe")
|
||||||
|
|
||||||
firefox_service = Service(chromedriver_path)
|
webdriver_service = Service(chromedriver_path)
|
||||||
driver = webdriver.Firefox(service=firefox_service)
|
driver = webdriver.Firefox(service=webdriver_service)
|
||||||
|
|
||||||
|
if browser == "edge":
|
||||||
|
# default os is linux/mac
|
||||||
|
# download url: https://developer.microsoft.com/zh-tw/microsoft-edge/tools/webdriver/
|
||||||
|
chromedriver_path = os.path.join(webdriver_path,"msedgedriver")
|
||||||
|
if platform.system().lower()=="windows":
|
||||||
|
chromedriver_path = os.path.join(webdriver_path,"msedgedriver.exe")
|
||||||
|
|
||||||
|
webdriver_service = Service(chromedriver_path)
|
||||||
|
driver = webdriver.Edge(service=webdriver_service)
|
||||||
|
|
||||||
#print("try to close opened tabs.")
|
#print("try to close opened tabs.")
|
||||||
'''
|
'''
|
||||||
|
@ -5372,6 +5383,7 @@ def urbtix_performance_confirm_dialog_popup(driver):
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def urbtix_main(driver, url, config_dict):
|
def urbtix_main(driver, url, config_dict):
|
||||||
# http://msg.urbtix.hk
|
# http://msg.urbtix.hk
|
||||||
waiting_for_access_url = ['/session/landing-timer/','msg.urbtix.hk','busy.urbtix.hk']
|
waiting_for_access_url = ['/session/landing-timer/','msg.urbtix.hk','busy.urbtix.hk']
|
||||||
|
@ -7201,7 +7213,7 @@ def main():
|
||||||
answer_index = -1
|
answer_index = -1
|
||||||
kktix_register_status_last = None
|
kktix_register_status_last = None
|
||||||
|
|
||||||
DISCONNECTED_MSG = 'Unable to evaluate script: no such window: target window already closed'
|
DISCONNECTED_MSG = ': target window already closed'
|
||||||
|
|
||||||
ocr = None
|
ocr = None
|
||||||
Captcha_Browser = None
|
Captcha_Browser = None
|
||||||
|
@ -7244,14 +7256,26 @@ def main():
|
||||||
driver.switch_to.window(driver.window_handles[0])
|
driver.switch_to.window(driver.window_handles[0])
|
||||||
driver.switch_to.default_content()
|
driver.switch_to.default_content()
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
else:
|
except Exception as excSwithFail:
|
||||||
if DISCONNECTED_MSG in driver.get_log('driver')[-1]['message']:
|
#print("excSwithFail:", excSwithFail)
|
||||||
|
pass
|
||||||
|
if window_handles_count==0:
|
||||||
|
try:
|
||||||
|
driver_log = driver.get_log('driver')[-1]['message']
|
||||||
|
print("get_log:", driver_log)
|
||||||
|
if DISCONNECTED_MSG in driver_log:
|
||||||
print('quit bot by NoSuchWindowException')
|
print('quit bot by NoSuchWindowException')
|
||||||
driver.quit()
|
driver.quit()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
break
|
break
|
||||||
except Exception as excSwithFail:
|
except Exception as excGetDriverMessageFail:
|
||||||
pass
|
#print("excGetDriverMessageFail:", excGetDriverMessageFail)
|
||||||
|
except_string = str(excGetDriverMessageFail)
|
||||||
|
if 'HTTP method not allowed' in except_string:
|
||||||
|
print('quit bot by close browser')
|
||||||
|
driver.quit()
|
||||||
|
sys.exit()
|
||||||
|
break
|
||||||
|
|
||||||
except UnexpectedAlertPresentException as exc1:
|
except UnexpectedAlertPresentException as exc1:
|
||||||
# PS: DON'T remove this line.
|
# PS: DON'T remove this line.
|
||||||
|
|
37
settings.py
37
settings.py
|
@ -19,7 +19,7 @@ import json
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import pyperclip
|
import pyperclip
|
||||||
|
|
||||||
CONST_APP_VERSION = u"MaxBot (2023.02.05)"
|
CONST_APP_VERSION = u"MaxBot (2023.02.06)"
|
||||||
|
|
||||||
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"
|
||||||
|
@ -43,6 +43,9 @@ URL_DONATE = 'https://max-everyday.com/about/#donate'
|
||||||
URL_HELP = 'https://max-everyday.com/2018/03/tixcraft-bot/'
|
URL_HELP = 'https://max-everyday.com/2018/03/tixcraft-bot/'
|
||||||
URL_RELEASE = 'https://github.com/max32002/tixcraft_bot/releases'
|
URL_RELEASE = 'https://github.com/max32002/tixcraft_bot/releases'
|
||||||
URL_FB = 'https://www.facebook.com/maxbot.ticket'
|
URL_FB = 'https://www.facebook.com/maxbot.ticket'
|
||||||
|
URL_CHROME_DRIVER = 'https://chromedriver.chromium.org/'
|
||||||
|
URL_FIREFOX_DRIVER = 'https://github.com/mozilla/geckodriver/releases'
|
||||||
|
URL_EDGE_DRIVER = 'https://developer.microsoft.com/zh-tw/microsoft-edge/tools/webdriver/'
|
||||||
|
|
||||||
def load_translate():
|
def load_translate():
|
||||||
translate = {}
|
translate = {}
|
||||||
|
@ -1563,7 +1566,7 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X):
|
||||||
|
|
||||||
global combo_browser
|
global combo_browser
|
||||||
combo_browser = ttk.Combobox(frame_group_header, state="readonly")
|
combo_browser = ttk.Combobox(frame_group_header, state="readonly")
|
||||||
combo_browser['values']= ("chrome","firefox")
|
combo_browser['values']= ("chrome","firefox","edge")
|
||||||
combo_browser.set(config_dict['browser'])
|
combo_browser.set(config_dict['browser'])
|
||||||
combo_browser.grid(column=1, row=group_row_count, sticky = W)
|
combo_browser.grid(column=1, row=group_row_count, sticky = W)
|
||||||
|
|
||||||
|
@ -1776,6 +1779,34 @@ def AboutTab(root, language_code):
|
||||||
lbl_fb_fans_url.grid(column=1, row=group_row_count, sticky = W)
|
lbl_fb_fans_url.grid(column=1, row=group_row_count, sticky = W)
|
||||||
lbl_fb_fans_url.bind("<Button-1>", lambda e: open_url(URL_FB))
|
lbl_fb_fans_url.bind("<Button-1>", lambda e: open_url(URL_FB))
|
||||||
|
|
||||||
|
|
||||||
|
group_row_count +=1
|
||||||
|
|
||||||
|
lbl_chrome_driver = Label(frame_group_header, text=u'Chrome Driver')
|
||||||
|
lbl_chrome_driver.grid(column=0, row=group_row_count, sticky = E)
|
||||||
|
|
||||||
|
lbl_chrome_driver_url = Label(frame_group_header, text=URL_CHROME_DRIVER, fg="blue", cursor="hand2")
|
||||||
|
lbl_chrome_driver_url.grid(column=1, row=group_row_count, sticky = W)
|
||||||
|
lbl_chrome_driver_url.bind("<Button-1>", lambda e: open_url(URL_CHROME_DRIVER))
|
||||||
|
|
||||||
|
group_row_count +=1
|
||||||
|
|
||||||
|
lbl_firefox_driver = Label(frame_group_header, text=u'Firefox Driver')
|
||||||
|
lbl_firefox_driver.grid(column=0, row=group_row_count, sticky = E)
|
||||||
|
|
||||||
|
lbl_firefox_driver_url = Label(frame_group_header, text=URL_FIREFOX_DRIVER, fg="blue", cursor="hand2")
|
||||||
|
lbl_firefox_driver_url.grid(column=1, row=group_row_count, sticky = W)
|
||||||
|
lbl_firefox_driver_url.bind("<Button-1>", lambda e: open_url(URL_FIREFOX_DRIVER))
|
||||||
|
|
||||||
|
group_row_count +=1
|
||||||
|
|
||||||
|
lbl_edge_driver = Label(frame_group_header, text=u'Edge Driver')
|
||||||
|
lbl_edge_driver.grid(column=0, row=group_row_count, sticky = E)
|
||||||
|
|
||||||
|
lbl_edge_driver_url = Label(frame_group_header, text=URL_EDGE_DRIVER, fg="blue", cursor="hand2")
|
||||||
|
lbl_edge_driver_url.grid(column=1, row=group_row_count, sticky = W)
|
||||||
|
lbl_edge_driver_url.bind("<Button-1>", lambda e: open_url(URL_EDGE_DRIVER))
|
||||||
|
|
||||||
frame_group_header.grid(column=0, row=row_count)
|
frame_group_header.grid(column=0, row=row_count)
|
||||||
|
|
||||||
def get_action_bar(root, language_code):
|
def get_action_bar(root, language_code):
|
||||||
|
@ -1856,7 +1887,7 @@ def main():
|
||||||
|
|
||||||
load_GUI(root, config_dict)
|
load_GUI(root, config_dict)
|
||||||
|
|
||||||
GUI_SIZE_WIDTH = 460
|
GUI_SIZE_WIDTH = 500
|
||||||
GUI_SIZE_HEIGHT = 594
|
GUI_SIZE_HEIGHT = 594
|
||||||
|
|
||||||
GUI_SIZE_MACOS = str(GUI_SIZE_WIDTH) + 'x' + str(GUI_SIZE_HEIGHT)
|
GUI_SIZE_MACOS = str(GUI_SIZE_WIDTH) + 'x' + str(GUI_SIZE_HEIGHT)
|
||||||
|
|
Loading…
Reference in New Issue