我是python的新手。感谢任何帮助。我使用selenium webdriver在python中开发了一个脚本,它生成报告并从网站获取快照。我已经在其他人的笔记本电脑上测试了它正确的裁剪。但是当我将它部署在远程桌面(窗口)并运行它时,裁剪变得混乱。
我在这里粘贴了代码。我使用flex中的两个元素 那些点作为参考点我已经定义了作物点,所以不知何故我 我不是很难编写这一点。
element=WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,'//*[@id="LineChart"]')))
location = element.location
size = element.size
height_header=size['height']
top_wan=top = location['y']
element=WebDriverWait(driver,10).until(EC.presence_of_element_located((By.ID,'chartContainer')))
location = element.location
size = element.size
driver.save_screenshot(fold_path+'\\Reports\\Screenshots\\LAN_traffic_by_apps_bidir'+str(x)+'_for_ref_site_'+str(ref_site)+'.png') # saves screenshot of entire page.
im=Image.open(fold_path+'\\Reports\\Screenshots\\LAN_traffic_by_apps_bidir'+str(x)+'_for_ref_site_'+str(ref_site)+'.png')
left = location['x']
top = location['y']+ 3 *height_header + 4
right = location['x'] + size['width']
bottom= location['y'] + 25 *height_header - 2
height_all_row=size['height']
im = im.crop((left, top, right, bottom)) # defines crop points