def every_downloads_chrome(driver,i): if not driver.current_url.startswith("chrome://downloads"): driver.get("chrome://downloads/") a=driver.execute_script('return document.querySelector("body > downloads-manager").shadowRoot.querySelector("#frb{}").shadowRoot.querySelector("#description").textContent.search("/")'.format(i)) if a==-1: return False #这时候就睡眠 else: return True