while True: if any(["Puffy" in h1.text.replace('uFEFF', "") for h1 in driver.find_elements_by_class_name("name-link")]): break else: driver.refresh driver.find_element_by_xpath("//*[contains(., 'Puffy')]").click()