Created
August 29, 2025 19:26
-
-
Save saamerm/0697bf48a77d22005d87b276f3f50832 to your computer and use it in GitHub Desktop.
Automation for Tawk.to in order to automatically add triggers based on translation for different languages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Automation for Tawk.to in order to automatically add triggers based on translation for different languages | |
| # Lines 338 and 339 should contain the username and password of your tawk.to account | |
| # Since localization and internationalization aren't supported, you can use this as a workaround | |
| from selenium import webdriver | |
| from selenium.webdriver.common.by import By | |
| from selenium.webdriver.common.keys import Keys | |
| from selenium.webdriver.common.action_chains import ActionChains | |
| from selenium.webdriver.support.ui import WebDriverWait | |
| from selenium.webdriver.support import expected_conditions as EC | |
| import time | |
| import os | |
| import threading | |
| languages = [ "en", "es", "fr", "pt", "ar", "ru", "de", "uk", "hi", "id", "it", "ja", "sw", "pl", "vi", "zh", "nl", "ko", "sv", "hu", "hr", "fa", "sq" "ro", "ur", "yo", ] | |
| translations = [ | |
| { | |
| "en": "Saamer - The Founder 📚", "es": "Saamer - El Fundador 📚", "fr": "Saamer - Le Fondateur 📚", "pt": "Saamer - O Fundador 📚", "ar": "سامر - المؤسس 📚", "ru": "Заамер - Основатель 📚", "de": "Saamer - Der Gründer 📚", "uk": "Саамер - Засновник 📚", "hi": "सामेर - संस्थापक 📚", "ur": "سمر - بانی 📚", "yo": "Saamer - Oludasile 📚", "id": "Saamer - Sang Pendiri 📚", "it": "Saamer - Il Fondatore 📚", "ja": "Saamer - 創設者 📚", "sw": "Saamer - Mwanzilishi 📚", "pl": "Saamer - Założyciel 📚", "vi": "Saamer - Người sáng lập 📚", "ro": "Saamer - Fondatorul 📚", "zh": "Saamer - 创始人📚", "hr": "Saamer - Osnivač 📚", "fa": "Saamer - The Founder 📚", "nl": "Saamer - De oprichter 📚", "ko": "Saamer - 창립자 📚", "sv": "Saamer - Grundaren 📚", "hu": "Saamer - Az alapító 📚", "sq": "Saamer - Themeluesi 📚" | |
| }, | |
| { | |
| "en": "👋 Want to chat about the world's fastest captioning & translation tool? I'm here to help you find your way. Ask me or select an option below", "es": "¿Quieres hablar sobre la herramienta de subtitulado y traducción más rápida del mundo? Estoy aquí para ayudarte a encontrar el camino. Pregúntame o selecciona una opción a continuación.", "fr": "👋 Envie de discuter de l'outil de sous-titrage et de traduction le plus rapide au monde ? Je suis là pour vous aider. Demandez-moi ou sélectionnez une option ci-dessous.", "pt": "👋 Quer conversar sobre a ferramenta de legendagem e tradução mais rápida do mundo? Estou aqui para ajudar você a encontrar o seu caminho. Pergunte-me ou selecione uma opção abaixo.", "ar": "👋 هل ترغب بالتحدث عن أسرع أداة ترجمة وتسميات توضيحية في العالم؟ أنا هنا لمساعدتك في إيجاد طريقك. اسألني أو اختر أحد الخيارات أدناه.", "ru": "👋 Хотите обсудить самый быстрый в мире инструмент для создания субтитров и перевода? Я здесь, чтобы помочь вам разобраться. Спросите меня или выберите вариант ниже.", "de": "👋 Möchten Sie über das schnellste Untertitelungs- und Übersetzungstool der Welt chatten? Ich helfe Ihnen gerne dabei. Fragen Sie mich oder wählen Sie unten eine Option aus.", "uk": "👋 Хочете поговорити про найшвидший у світі інструмент створення субтитрів і перекладу? Я тут, щоб допомогти тобі знайти свій шлях. Запитайте мене або виберіть варіант нижче", "hi": "👋 क्या आप दुनिया के सबसे तेज़ कैप्शनिंग और अनुवाद टूल के बारे में बात करना चाहते हैं? मैं आपकी मदद के लिए यहाँ हूँ। मुझसे पूछें या नीचे दिए गए विकल्पों में से कोई एक चुनें।", "ur": "👋 کیا آپ دنیا کے تیز ترین کیپشن اور ترجمے کے ٹول کے بارے میں بات کرنا چاہتے ہیں؟ میں آپ کا راستہ تلاش کرنے میں آپ کی مدد کرنے کے لیے حاضر ہوں۔ مجھ سے پوچھیں یا نیچے ایک آپشن منتخب کریں۔", "yo": "👋 Ṣe o fẹ lati jiroro nipa akọle ti o yara ju ni agbaye & irinṣẹ itumọ bi? Mo wa nibi lati ran ọ lọwọ lati wa ọna rẹ. Beere lọwọ mi tabi yan aṣayan kan ni isalẹ", "id": "👋 Ingin berdiskusi tentang alat teks & terjemahan tercepat di dunia? Saya siap membantu Anda. Tanyakan kepada saya atau pilih opsi di bawah ini.", "it": "👋 Vuoi parlare dello strumento di traduzione e sottotitolazione più veloce al mondo? Sono qui per aiutarti a trovare la soluzione. Chiedimelo o seleziona un'opzione qui sotto.", "ja": "👋 世界最速の字幕・翻訳ツールについてお話しませんか?お手伝いさせていただきます。お気軽にご質問いただくか、以下のオプションからお選びください。", "sw": "👋 Je, ungependa kupiga gumzo kuhusu zana ya haraka zaidi ya manukuu na ya kutafsiri? Niko hapa kukusaidia kutafuta njia yako. Niulize au chagua chaguo hapa chini", "pl": "👋 Chcesz porozmawiać o najszybszym na świecie narzędziu do tworzenia napisów i tłumaczeń? Jestem tu, aby pomóc Ci znaleźć drogę. Zapytaj mnie lub wybierz opcję poniżej.", "vi": "👋 Bạn muốn trò chuyện về công cụ dịch thuật và phụ đề nhanh nhất thế giới? Tôi luôn sẵn sàng hỗ trợ bạn. Hãy hỏi tôi hoặc chọn một tùy chọn bên dưới", "ro": "👋 Doriți să discutați despre cel mai rapid instrument de subtitrare și traducere din lume? Sunt aici să te ajut să-ți găsești drumul. Întrebați-mă sau selectați o opțiune de mai jos", "zh": "👋 想聊聊世界上最快的字幕和翻译工具吗?我会帮你找到方法。你可以问我,或者选择下面的选项。", "hr": "👋 Želite razgovarati o najbržem alatu za titlove i prijevod na svijetu? Ovdje sam da ti pomognem pronaći svoj put. Pitajte me ili odaberite opciju ispod", "fa": "👋 آیا میخواهید درباره سریعترین ابزار زیرنویس و ترجمه جهان گپ بزنید؟ من اینجا هستم تا به شما کمک کنم راه خود را پیدا کنید. از من بپرسید یا یکی از گزینه های زیر را انتخاب کنید", "nl": "👋 Wil je chatten over 's werelds snelste ondertitelings- en vertaaltool? Ik help je graag op weg. Stel me je vraag of selecteer een optie hieronder.", "ko": "👋 세계에서 가장 빠른 자막 및 번역 도구에 대해 이야기 나누고 싶으신가요? 제가 도와드리겠습니다. 문의하시거나 아래에서 옵션을 선택하세요.", "sv": "👋 Vill du chatta om världens snabbaste verktyg för textning och översättning? Jag är här för att hjälpa dig hitta din väg. Fråga mig eller välj ett alternativ nedan", "hu": "👋 Szeretne csevegni a világ leggyorsabb feliratozó és fordító eszközéről? Azért vagyok itt, hogy segítsek eligazodni. Kérdezzen, vagy válasszon az alábbi lehetőségek közül", "sq": "👋 Dëshironi të bisedoni për mjetin më të shpejtë të titrave dhe përkthimit në botë? Unë jam këtu për t'ju ndihmuar të gjeni rrugën tuaj. Më pyet ose zgjidh një opsion më poshtë" | |
| }, | |
| { | |
| "en": "📄 Get free training", "es": "📄 Obtén formación gratuita", "fr": "📄 Obtenez une formation gratuite", "pt": "📄 Obtenha treinamento gratuito", "ar": "📄 احصل على تدريب مجاني", "ru": "📄 Получите бесплатное обучение", "de": "📄 Kostenlose Schulung", "uk": "📄 Пройдіть безкоштовне навчання", "hi": "📄 निःशुल्क प्रशिक्षण प्राप्त करें", "ur": "📄 مفت تربیت حاصل کریں۔", "yo": "📄 Gba ikẹkọ ọfẹ", "id": "📄 Dapatkan pelatihan gratis", "it": "📄 Ottieni una formazione gratuita", "ja": "📄無料トレーニングを受ける", "sw": "📄 Pata mafunzo bila malipo", "pl": "📄 Otrzymaj bezpłatne szkolenie", "vi": "📄 Nhận đào tạo miễn phí", "ro": "📄 Primiți antrenament gratuit", "zh": "📄 获得免费培训", "hr": "📄 Dobijte besplatnu obuku", "fa": "📄 آموزش رایگان دریافت کنید", "nl": "📄 Ontvang gratis training", "ko": "📄 무료 교육 받기", "sv": "📄 Få gratis träning", "hu": "📄 Ingyenes képzés", "sq": "📄 Merrni trajnim falas" | |
| }, | |
| { | |
| "en": "🚀 Get started free", "es": "🚀 Empieza gratis", "fr": "🚀 Commencez gratuitement", "pt": "🚀 Comece gratuitamente", "ar": "🚀ابدأ مجانًا", "ru": "🚀 Начните бесплатно", "de": "🚀 Kostenlos starten", "uk": "🚀 Почніть безкоштовно", "hi": "🚀 निःशुल्क आरंभ करें", "ur": "🚀 مفت شروع کریں۔", "yo": "🚀 Bẹrẹ ọfẹ", "id": "🚀 Mulai gratis", "it": "🚀 Inizia gratuitamente", "ja": "🚀 無料で始める", "sw": "🚀 Anza bila malipo", "pl": "🚀 Zacznij za darmo", "vi": "🚀 Bắt đầu miễn phí", "ro": "🚀 Începe gratuit", "zh": "🚀 免费开始", "hr": "🚀 Započnite besplatno", "fa": "🚀 رایگان شروع کنید", "nl": "🚀 Gratis aan de slag", "ko": "🚀 무료로 시작하세요", "sv": "🚀 Kom igång gratis", "hu": "🚀 Kezdje el ingyen", "sq": "🚀 Filloni falas" | |
| }, | |
| { | |
| "en": "💬 Chat with the sales team", "es": "💬 Chatea con el equipo de ventas", "fr": "💬 Discutez avec l'équipe commerciale", "pt": "💬 Converse com a equipe de vendas", "ar": "💬 الدردشة مع فريق المبيعات", "ru": "💬 Пообщайтесь с отделом продаж", "de": "💬 Chatten Sie mit dem Verkaufsteam", "uk": "💬 Спілкуйтеся з відділом продажів", "hi": "💬 बिक्री टीम के साथ चैट करें", "ur": "💬 سیلز ٹیم کے ساتھ چیٹ کریں۔", "yo": "💬 Wiregbe pẹlu ẹgbẹ tita", "id": "💬 Ngobrol dengan tim penjualan", "it": "💬 Chatta con il team di vendita", "ja": "💬 営業チームとチャット", "sw": "💬 Ongea na timu ya mauzo", "pl": "💬 Porozmawiaj z zespołem sprzedaży", "vi": "💬 Trò chuyện với đội ngũ bán hàng", "ro": "💬 Discutați cu echipa de vânzări", "zh": "💬 与销售团队聊天", "hr": "💬 Razgovarajte s prodajnim timom", "fa": "💬 با تیم فروش چت کنید", "nl": "💬 Chat met het verkoopteam", "ko": "💬 영업팀과 채팅하세요", "sv": "💬 Chatta med säljteamet", "hu": "💬 Csevegés az értékesítési csapattal", "sq": "💬 Bisedoni me ekipin e shitjeve" | |
| } | |
| ] | |
| def run_browser(lang, driver): | |
| # Go to the new trigger page | |
| wait = WebDriverWait(driver, 15) | |
| # --- 1. Select Trigger Type --- | |
| trigger_dropdown = wait.until(EC.element_to_be_clickable((By.XPATH, "//label[text()='Trigger Type']/following::button[1]"))) | |
| trigger_dropdown.click() | |
| time.sleep(1) # tiny pause | |
| # Choose "Basic - Chat Rescuer" | |
| chat_rescuer_option = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[contains(@class,'tawk-dropdown-item')]//div[text()='Basic - Chat Rescuer']"))) | |
| chat_rescuer_option.click() | |
| time.sleep(1) # let UI refresh | |
| # --- 2. Fill Trigger Name --- | |
| # trigger_name = wait.until(EC.element_to_be_clickable((By.XPATH, "//label[text()='Trigger Name']/following::input[1]"))) | |
| # trigger_name.clear() | |
| # trigger_name.send_keys("Polski testowy wyzwalacz") # Polish text | |
| # --- Step 1: Open the "Trigger Type" dropdown --- | |
| trigger_dropdown_button = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//label[text()='Trigger Type']/following::button[1]")) | |
| ) | |
| trigger_dropdown_button.click() | |
| time.sleep(1) # tiny pause | |
| # --- Step 2: Select "Advanced" from dropdown --- | |
| advanced_option = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//li[@class='tawk-dropdown-list-item change-item']//div[text()='Advanced']")) | |
| ) | |
| advanced_option.click() | |
| time.sleep(1) # tiny pause | |
| # --- Step 3: Fill in "Trigger Name" --- | |
| trigger_name_input = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//label[text()='Trigger Name']/following::input[1]")) | |
| ) | |
| trigger_name_input.clear() | |
| trigger_name_input.send_keys("Index-" + lang) | |
| # --- Step 4: Fill in "Trigger Description" --- | |
| trigger_description = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//label[text()='Trigger Description']/following::textarea[1]")) | |
| ) | |
| trigger_description.clear() | |
| trigger_description.send_keys("Index-" + lang) | |
| # --- Step 1: Change "Hour of day" → "Visitor page URL" --- | |
| condition_type_button = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//div[contains(@class,'trigger-condition-type')]//button")) | |
| ) | |
| condition_type_button.click() | |
| time.sleep(1) # tiny pause | |
| # Find the dropdown option | |
| visitor_url_option = wait.until( | |
| EC.presence_of_element_located((By.XPATH, "//div[text()='Visitor page URL']")) | |
| ) | |
| # Scroll into view before clicking | |
| actions = ActionChains(driver) | |
| actions.move_to_element(visitor_url_option).perform() | |
| visitor_url_option.click() | |
| time.sleep(1) # tiny pause | |
| # --- Step 2: Change "Equals" → "Contains" --- | |
| operation_button = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//div[contains(@class,'trigger-condition-operation')]//button")) | |
| ) | |
| operation_button.click() | |
| time.sleep(1) # tiny pause | |
| contains_option = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//div[text()='Contains']")) | |
| ) | |
| contains_option.click() | |
| time.sleep(1) # tiny pause | |
| # --- Step 3: Enter "index-pl.html" in the value field --- | |
| value_input = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//div[contains(@class,'trigger-condition-option')]//input")) | |
| ) | |
| value_input.clear() | |
| value_input.send_keys("index-" + lang + ".html") | |
| # # --- Step ?: Tap on the older action `Send message to visitor` and select "Wait" instead --- | |
| dropdown_button = WebDriverWait(driver, 10).until( | |
| # EC.element_to_be_clickable((By.CSS_SELECTOR, ".tawk-dropdown .tawk-button")) | |
| # EC.element_to_be_clickable((By.XPATH, "//label[text()='Send message to visitor']/following::button[1]")) | |
| EC.element_to_be_clickable((By.XPATH, "//button[.//span[contains(text(), 'Send message to visitor')]]")) | |
| ) | |
| driver.execute_script("arguments[0].scrollIntoView(true);", dropdown_button) # scroll to dropdown | |
| dropdown_button.click() | |
| time.sleep(1) # tiny pause | |
| advanced_option = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//li[@class='tawk-dropdown-list-item change-item']//div[text()='Wait']")) | |
| ) | |
| advanced_option.click() | |
| time.sleep(1) # tiny pause | |
| dropdown_button = WebDriverWait(driver, 10).until( | |
| # EC.element_to_be_clickable((By.CSS_SELECTOR, ".tawk-dropdown .tawk-button")) | |
| # EC.element_to_be_clickable((By.XPATH, "//label[text()='Send message to visitor']/following::button[1]")) | |
| EC.element_to_be_clickable((By.XPATH, "//button[.//span[contains(text(), 'No Delay')]]")) | |
| ) | |
| driver.execute_script("arguments[0].scrollIntoView(true);", dropdown_button) # scroll to dropdown | |
| dropdown_button.click() | |
| time.sleep(1) # tiny pause | |
| advanced_option = wait.until( | |
| EC.element_to_be_clickable((By.XPATH, "//li[@class='tawk-dropdown-list-item change-item']//div[text()='20 seconds']")) | |
| ) | |
| advanced_option.click() | |
| time.sleep(1) # tiny pause | |
| add_action_btn = WebDriverWait(driver, 10).until( | |
| EC.element_to_be_clickable( | |
| (By.XPATH, "//button[normalize-space()='Add Action']") | |
| ) | |
| ) | |
| driver.execute_script("arguments[0].scrollIntoView(true);", add_action_btn) | |
| add_action_btn.click() | |
| time.sleep(1) # tiny pause | |
| print("lang: " + lang) | |
| # get your home Downloads folder | |
| downloads_path = os.path.join(os.path.expanduser("~"), "Downloads") | |
| # full path to your file | |
| file_path = os.path.join(downloads_path, "!!200x200.jpg") | |
| # sanity check | |
| if not os.path.exists(file_path): | |
| raise FileNotFoundError(f"File not found at {file_path}") | |
| # 🔑 Instead of clicking the upload button, just send the path to the file input | |
| file_input = WebDriverWait(driver, 10).until( | |
| EC.presence_of_element_located((By.XPATH, "//input[@type='file' and @accept='image/png, image/jpeg']")) | |
| ) | |
| driver.execute_script("arguments[0].style.border='3px solid red'", file_input) # debug highlight | |
| file_input.send_keys(file_path) # <-- this directly uploads the file | |
| # trigger change event if the site listens for it | |
| driver.execute_script("arguments[0].dispatchEvent(new Event('change', { bubbles: true }))", file_input) | |
| # 4. Click "Add Message" button | |
| # add_msg_btn = WebDriverWait(driver, 10).until( | |
| # EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Done']")) | |
| # ) | |
| # add_msg_btn.click() | |
| done_msg_btn = WebDriverWait(driver, 10).until( | |
| EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Done']")) | |
| ) | |
| driver.execute_script("arguments[0].scrollIntoView(true);", done_msg_btn) | |
| time.sleep(1) # tiny pause | |
| # from selenium.webdriver.common.action_chains import ActionChains | |
| ActionChains(driver).move_to_element(done_msg_btn).click().perform() | |
| # add_msg_btn = WebDriverWait(driver, 10).until( | |
| # EC.presence_of_element_located((By.XPATH, "//button[normalize-space()='Done']")) | |
| # ) | |
| # driver.execute_script("arguments[0].click();", done_msg_btn) | |
| WebDriverWait(driver, 10).until_not( | |
| EC.presence_of_element_located((By.XPATH, "//div[contains(@class, 'overlay')]")) | |
| ) | |
| # Then click Done | |
| # add_msg_btn = WebDriverWait(driver, 10).until( | |
| # EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Done']")) | |
| # ) | |
| # add_msg_btn.click() | |
| time.sleep(1) # tiny pause | |
| WebDriverWait(driver, 10).until_not( | |
| EC.presence_of_element_located((By.XPATH, "//div[contains(@class, 'overlay')]")) | |
| ) | |
| # 1. Fill Agent Name | |
| agent_name_input = WebDriverWait(driver, 10).until( | |
| EC.presence_of_element_located((By.XPATH, "//input[@placeholder='Enter Agent Name']")) | |
| ) | |
| agent_name_input.clear() | |
| # agent_name_input.send_keys(translations[0][lang]) | |
| driver.execute_script(""" | |
| arguments[0].value = arguments[1]; | |
| arguments[0].dispatchEvent(new Event('input', { bubbles: true })); | |
| arguments[0].dispatchEvent(new Event('change', { bubbles: true })); | |
| """, agent_name_input, translations[0][lang]) | |
| # 2. Fill Trigger Message | |
| trigger_msg_input = WebDriverWait(driver, 10).until( | |
| EC.presence_of_element_located((By.XPATH, "//textarea[@placeholder='Enter Trigger Message']")) | |
| ) | |
| trigger_msg_input.clear() | |
| # trigger_msg_input.send_keys(translations[1][lang]) | |
| driver.execute_script(""" | |
| arguments[0].value = arguments[1]; | |
| arguments[0].dispatchEvent(new Event('input', { bubbles: true })); | |
| arguments[0].dispatchEvent(new Event('change', { bubbles: true })); | |
| """, trigger_msg_input, translations[1][lang]) | |
| time.sleep(1) # tiny pause | |
| # 3. Fill first "Enter Message" field | |
| first_msg_input = WebDriverWait(driver, 10).until( | |
| EC.presence_of_element_located((By.XPATH, "(//input[@placeholder='Enter Message'])[1]")) | |
| ) | |
| first_msg_input.clear() | |
| # first_msg_input.send_keys(translations[2][lang]) | |
| driver.execute_script(""" | |
| arguments[0].value = arguments[1]; | |
| arguments[0].dispatchEvent(new Event('input', { bubbles: true })); | |
| arguments[0].dispatchEvent(new Event('change', { bubbles: true })); | |
| """, first_msg_input, translations[2][lang]) | |
| # 4. Click "Add Message" button | |
| add_msg_btn = WebDriverWait(driver, 10).until( | |
| EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Add Message']")) | |
| ) | |
| add_msg_btn.click() | |
| time.sleep(1) # tiny pause | |
| # 5. Fill second "Enter Message" field (the new one that appears) | |
| second_msg_input = WebDriverWait(driver, 10).until( | |
| EC.presence_of_element_located((By.XPATH, "(//input[@placeholder='Enter Message'])[2]")) | |
| ) | |
| second_msg_input.clear() | |
| driver.execute_script(""" | |
| arguments[0].value = arguments[1]; | |
| arguments[0].dispatchEvent(new Event('input', { bubbles: true })); | |
| arguments[0].dispatchEvent(new Event('change', { bubbles: true })); | |
| """, second_msg_input, translations[3][lang]) | |
| # second_msg_input.send_keys(translations[3][lang]) | |
| # 6. Click "Add Message" button | |
| add_msg_btn = WebDriverWait(driver, 10).until( | |
| EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Add Message']")) | |
| ) | |
| add_msg_btn.click() | |
| time.sleep(1) # tiny pause | |
| # 7. Fill third "Enter Message" field (the new one that appears) | |
| second_msg_input = WebDriverWait(driver, 10).until( | |
| EC.presence_of_element_located((By.XPATH, "(//input[@placeholder='Enter Message'])[3]")) | |
| ) | |
| second_msg_input.clear() | |
| # second_msg_input.send_keys(translations[4][lang]) | |
| driver.execute_script(""" | |
| arguments[0].value = arguments[1]; | |
| arguments[0].dispatchEvent(new Event('input', { bubbles: true })); | |
| arguments[0].dispatchEvent(new Event('change', { bubbles: true })); | |
| """, second_msg_input, translations[4][lang]) | |
| WebDriverWait(driver, 10).until_not( | |
| EC.presence_of_element_located((By.XPATH, "//div[contains(@class, 'overlay')]")) | |
| ) | |
| save_msg_btn = WebDriverWait(driver, 10).until( | |
| EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Save']")) | |
| ) | |
| save_msg_btn.click() | |
| driver.execute_script("arguments[0].scrollIntoView(true);", save_msg_btn) | |
| time.sleep(1) # tiny pause | |
| # driver.execute_script("arguments[0].scrollIntoView(true);", save_msg_btn) | |
| # add_msg_btn = WebDriverWait(driver, 10).until( | |
| # EC.presence_of_element_located((By.XPATH, "//button[normalize-space()='Done']")) | |
| # ) | |
| WebDriverWait(driver, 10).until_not( | |
| EC.presence_of_element_located((By.XPATH, "//div[contains(@class, 'overlay')]")) | |
| ) | |
| add_trigger_msg_btn = WebDriverWait(driver, 10).until( | |
| EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Add Trigger']")) | |
| ) | |
| # add_msg_btn.click() | |
| driver.execute_script("arguments[0].scrollIntoView(true);", add_trigger_msg_btn) | |
| ActionChains(driver).move_to_element(add_trigger_msg_btn).click().perform() | |
| time.sleep(1) # tiny pause | |
| print("lang: " + lang + " - Done!") | |
| # --- Optionally wait for Welcome! text --- | |
| # wait.until(EC.presence_of_element_located((By.XPATH, "//*[contains(text(), 'Welcome!')]"))) | |
| # print("Login successful!") | |
| # threads = [] | |
| # Start driver (example with Chrome) | |
| driver = webdriver.Chrome() | |
| # Go to the page | |
| driver.get("https://dashboard.tawk.to/#/admin/67291e984304e3196add0224/settings/triggers/new") | |
| wait = WebDriverWait(driver, 15) | |
| # Wait for email input to be interactable | |
| email_field = wait.until(EC.element_to_be_clickable((By.ID, "email"))) | |
| password_field = wait.until(EC.element_to_be_clickable((By.ID, "password"))) | |
| # Clear (sometimes values exist by default) | |
| email_field.clear() | |
| password_field.clear() | |
| # Send keys | |
| email_field.send_keys("{}") | |
| password_field.send_keys("{}") | |
| # Click Sign In button | |
| login_button = driver.find_element(By.ID, "submit-login") | |
| login_button.click() | |
| for lang in languages: | |
| run_browser(lang, driver) | |
| # email = translations[0][lang] | |
| # password = translations[1][lang] | |
| # t = threading.Thread(target=run_browser, args=(lang)) | |
| # t.start() | |
| # threads.append(t) | |
| # Wait for all to finish | |
| # for t in threads: | |
| # t.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment