我试图在画布高度发生变化时截取网页的屏幕截图。它的默认高度是 557。我希望 selenium 等待高度更改为 557 以外的任何其他值。有什么办法可以做到这一点吗?
<canvas id="faceCanvasPhoto" width="600" height="557" class="center-block reportCanvas">
Your browser does not support the canvas element.
</canvas>
Run Code Online (Sandbox Code Playgroud)
我尝试了 EC.visibility_of_element_ located 但无法捕获它
try:
WebDriverWait(driver, 5).until(EC.visibility_of_element_located((By.XPATH, "//*[@id='faceCanvasPhoto']"))
)
driver.find_element_by_tag_name('body').screenshot(facemap +'.png')
except TimeoutException:
driver.find_element_by_tag_name('body').screenshot(facemap +'.png')
driver.implicitly_wait(1)
Run Code Online (Sandbox Code Playgroud) 如果路径不存在,则代码可以正常工作,但是当年份(2021)文件夹存在时,它只会在第一个条件后停止工作
def check_path():
from datetime import datetime, timedelta
dt = datetime.today()
year = str(dt.year)
month = str(dt.month)
day = str(dt.day)
path = os.path.join( year)
if not os.path.exists(path):
os.mkdir(path)
path = os.path.join(path, month)
if not os.path.exists(path):
os.mkdir(path)
path = os.path.join(path, day)
if not os.path.exists(path):
os.mkdir(path)
Run Code Online (Sandbox Code Playgroud)
我想要的最终结果是 //2021//08//创建了 26 个文件夹