你做了幾件不同的事。您可以在上面提到的xpath中: message_button = WebDriverWait(self.driver, 20).until( EC.element_to_be_clickable((By.XPATH, '//button/div[contains(text(), "Anybody")] | //span/div[contains(text(), "Somebody")]'))) python確實有any_of(在較新版本中)的行為類似于邏輯or: WebDriverWait(browser, 10).until( EC.any_of( EC.element_to_be_clickable((By.XPATH, '//button/div[contains(text(), "Anybody")]')), EC.element_to_be_clickable((By.XPATH, '//span/div[contains(text(), "Somebody")]'))) ))