这应该可以帮助您:from selenium import webdriverimport randomdriver = webdriver.Chrome()driver.get('url')elements = driver.find_elements_by_xpath('//*[@id]') #Finds all elements in the pageelement = random.choice(elements) #Selects a random element from the list of elementselement.click() #Clicks on the selected element