Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
Selenium Explicit/Fluent wait until service worker is installed

I am working on a selenium script to visit a list of websites that install service workers. What I want to do is, if selenium visits a website, it should wait for the service worker to be installed before moving on to the next website or quitting the selenium driver. Currently, my code looks like the following.

        for url in tqdm(list_urls):
            driver = get_driver() # gets driver from helper function.
            print(f'Doing {url} {list_urls.index(url)+1}/{len(list_urls)}')
            try:
                driver.get(url)
                sleep(10) # probably not the best way to do it.
            
            except: # if there is a selenium timeout exception.
                print(f'{url} did not work ... will try again.')
                repeat_list.append(url)
        
            driver.quit()

I have a sleep(10) which I do not think is the best way to do it. There is a possibility that the service worker is installed in 1 second (it sits idle for 9 seconds doing nothing) or the service worker was not installed in 10 seconds. I am going to do this for a list of websites at the scale of thousands. I understand there are implicit, explicit, and fluent wait statements in selenium but I have not found anything that is useful for me.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda