在頁面上,我有一個表格導出列表元素,它在幾秒鐘之後更改爲幾分鐘(等待,正在處理和已完成)或進度條完成爲100% 。 來源:Selenium python如何等待創建元素
<p id="2c92c0f953cfa2d80153e8409eggFeb9" class="ares_txt15"> Pending </p> </td>
要:
<p id="22c92c0f953cfa2d80153e6404bcc12c2" class="ares_txt15"> Completed
<script type="text/javascript"> var newPro0 = new ProgressBar('100'-0).appendTo('2c92c08653cf9ce60153e6cde69d57da'); </script>
<div class="iblock" style="vertical-align: middle; padding-left: 5px;">
<div class="iblock" style="width: 80px; height: 8px; border: 1px solid rgb(153, 153, 153); padding: 1px; font-size: 0px; vertical-align: middle; line-height: 0px;">
<div class="iblock" style="width: 80px; height: 8px; background: rgb(115, 194, 56) none repeat scroll 0% 0%; vertical-align: middle; font-size: 0px; line-height: 0px;"/>
</div>
<span class="iblock" style="padding: 0px 5px; line-height: 11px; vertical-align: middle;">100%</span>
</div>
</p
這是我有:
>>> all_data = browser.find_elements_by_xpath("//*[@class='ares_txt15']")
>>> for row in all_data:
print(row.text)
Pending
Completed 100%
Completed 100%
Completed 100%
Completed 100%
Completed 100%
try:
WebDriverWait(browser, 80).until(EC.presence_of_element_located((By.XPATH, '//*[@class="ares_text15" and contains(text(), "Completed 100%")]')))
except TimeoutException:
raise Exception('Unable to find text in this element after waiting 80 seconds')
Traceback (most recent call last):
File "<pyshell#56>", line 4, in <module>
raise Exception('Unable to find text in this element after waiting 80 seconds')
Exception: Unable to find text in this element after waiting 80 seconds
升起時間爲10秒60。看看它是否會爲你工作? –