Python:xPath单击动态创建的元素

Python:xPath单击动态创建的元素,python,xpath,selenium-webdriver,Python,Xpath,Selenium Webdriver,我正在使用Python和webdriver,并使用下面的代码 我正在尝试单击“全部查看”选项以列出页面上的所有产品,我可以单击显示可用选项的向下箭头,但我不能单击“全部查看”选项,有人知道我做错了什么吗 它只是说找不到第二个元素 driver = webdriver.Firefox() driver.get('http://www.boots.ie/webapp/wcs/stores/servlet/SearchDisplay?categoryId=&storeId=11353&

我正在使用Python和webdriver,并使用下面的代码

我正在尝试单击“全部查看”选项以列出页面上的所有产品,我可以单击显示可用选项的向下箭头,但我不能单击“全部查看”选项,有人知道我做错了什么吗

它只是说找不到第二个元素

driver = webdriver.Firefox()
driver.get('http://www.boots.ie/webapp/wcs/stores/servlet/SearchDisplay?categoryId=&storeId=11353&catalogId=28502&langId=-1&sType=SimpleSearch&resultCatEntryType=2&showResultsPage=true&searchSource=Q&pageView=&beginIndex=0&pageSize=24&manufacturer=lynx&isA2ZBrand=Y')

element = driver.find_element_by_xpath("//div[contains(@class, 'select_order')]/table")
element.click()
element = driver.find_element_by_xpath("//div[contains(@class, 'select_order')]/div[contains(@class, 'dijitSearchResultSelectSizeLabel')]")
element.click()

尝试添加一个
等待。直到
语句如下:

driver = webdriver.Firefox()

# Create wait element to be used later
# 10 represents the amount of seconds to wait before throwing TimeoutException
wait = ui.WebDriverWait(driver, 10)

driver.get('http://www.boots.ie/webapp/wcs/stores/servlet/SearchDisplay?categoryId=&storeId=11353&catalogId=28502&langId=-1&sType=SimpleSearch&resultCatEntryType=2&showResultsPage=true&searchSource=Q&pageView=&beginIndex=0&pageSize=24&manufacturer=lynx&isA2ZBrand=Y')

element = driver.find_element_by_xpath("//div[contains(@class, 'select_order')]/table")
element.click()

# Wait for element to pop up
wait.until(lambda driver: driver.find_element_by_xpath('//div[contains(@class, 'select_order')]/div[contains(@class, 'dijitSearchResultSelectSizeLabel')]'))

# Element popped up, now select & click it
element = driver.find_element_by_xpath("//div[contains(@class, 'select_order')]/div[contains(@class, 'dijitSearchResultSelectSizeLabel')]")
element.click()

以下是你问题的答案:

要单击
查看所有
选项以列出页面上的所有产品,单击显示可用选项的向下箭头后,接下来您可以使用元素的
id
单击它,如下所示:

element = driver.find_element_by_id("dijit_MenuItem_1_text")
element.click()

如果这回答了您的问题,请告诉我。

出现
错误:无法定位元素:dijit\u MenuItem\u 1\u text