Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!