I'm using the latest Firefox webdriver and selenium. I'm trying to make an inventory checker bot, where it periodically refreshes a bunch of pages. Because I have a lot of links, in order to save on memory, I've implemented it so that each page is opened in a different firefox tab.
In order to refresh a tab, I need to switch to it and then refresh the current page. However, driver.refresh()
takes ~10 seconds for some websites to refresh, and since I can't refresh any of the other pages in the meantime, it slows my workload considerably.
driver = webdriver.Firefox()
def refresh_page(self):
logging.info('Starting to refresh page %s', self.url)
self.switch_to()
time.sleep(self.delay)
# driver.find_element_by_tag_name('body').send_keys(Keys.F5)
driver.refresh()
logging.info('Finished refreshing page')
def switch_to(self):
driver.switch_to.window(self.tab)
Is there any way to refresh a page asynchronously? It looks like other people have run into the same issue: Asynchronous refresh with Selenium + Python.
Sending the F5 key does not work for some reason. I have also tried calling driver.get(self.url)
with no luck (Still synchronous). Another solution might be to find a way to synchronously reload all tabs at once, but I have not found a solution for that either.