0

I am using a script to automate a process, and I want to implement undetected chrome driver. However, when I do so, the script doesn't work correctly as it opens the Chrome window but closes it instantly. I believe it's an issue related to the Chrome driver. My Chrome version is 115.0.5790.110, and the webdriver-manager version is 3.9.1. Thank you in advance!

import requests
    from selenium import webdriver
    from selenium.webdriver.support.ui import Select
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from webdriver_manager.chrome import ChromeDriverManager
    from selenium.webdriver.chrome.options import Options
    from webdriver_manager.firefox import GeckoDriverManager
    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.chrome.service import Service
    import undetected_chromedriver 
    from bs4 import BeautifulSoup
    import time
    import os
    from selenium.webdriver.chrome.service import Service
    from selenium.webdriver.chrome.service import Service as ChromeService
    import asyncio
    import json
    
    #rest of the code...
    
    def main(): options = undetected_chromedriver.ChromeOptions() options.add_experimental_option('excludeSwitches', ['enable-logging'])
    file = open('link.txt', 'r')
    link = file.readlines()[0].strip()
    
    details_file = open('details.txt', 'r')
    data = details_file.readlines()
    data = [x.split('>')[-1].strip() for x in data]
    
    
    refresh_time = float(data[0].split('>')[-1].strip())
    
    while True:
        try:
            
            service = ChromeService()
            driver = undetected_chromedriver.Chrome(service=service, options=options)
            driver.get(link)
    
            condition = EC.visibility_of_element_located((By.CSS_SELECTOR, '#\\#tickets-iframe-m'))
            iframe = WebDriverWait(driver, 30).until(condition)
            driver.switch_to.frame(iframe)
    
            condition = EC.presence_of_element_located((By.CSS_SELECTOR, '#buynow'))
            first_option = WebDriverWait(driver, refresh_time).until(condition)
            os.system('sound.mp3')
            mensaje = 'A comprar mi loko'
            enviar_notificacion_telegram(mensaje)
    
            time.sleep(360)  # Esperar 5 minutos
    
            driver.close()
            driver.quit()
    #rest of the code...
Joako
  • 1

0 Answers0