Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在远程windows桌面上,使用PIL进行的图像裁剪未按预期进行裁剪_Python_Selenium_Selenium Webdriver_Python Imaging Library - Fatal编程技术网

Python 在远程windows桌面上,使用PIL进行的图像裁剪未按预期进行裁剪

Python 在远程windows桌面上,使用PIL进行的图像裁剪未按预期进行裁剪,python,selenium,selenium-webdriver,python-imaging-library,Python,Selenium,Selenium Webdriver,Python Imaging Library,我是python新手,非常感谢您的帮助。我使用SeleniumWebDriver在python中开发了一个脚本,它可以生成报告并从网站上获取快照。我已经在其他人的笔记本电脑上测试过它的裁剪是否正确。但是当我在远程桌面(windows)上部署它并运行它时,裁剪变得一团糟 我在这里粘贴了代码。我使用了flex中的两个元素 这些点作为参考点,我定义了裁剪点,所以我 我不是在硬编码这一点 到底发生了什么?使用上面的代码,当我在系统中运行脚本时,即使在我同事的笔记本电脑中,它也能非常清晰地从网页中裁剪出图

我是python新手,非常感谢您的帮助。我使用SeleniumWebDriver在python中开发了一个脚本,它可以生成报告并从网站上获取快照。我已经在其他人的笔记本电脑上测试过它的裁剪是否正确。但是当我在远程桌面(windows)上部署它并运行它时,裁剪变得一团糟

我在这里粘贴了代码。我使用了flex中的两个元素 这些点作为参考点,我定义了裁剪点,所以我 我不是在硬编码这一点


到底发生了什么?使用上面的代码,当我在系统中运行脚本时,即使在我同事的笔记本电脑中,它也能非常清晰地从网页中裁剪出图形。我已经开发了触发这个脚本的UI。所以我把它部署在远程windows机器上,那里的裁剪并不像预期的那样。这意味着它有时会上下移动,但左右位置与预期一致。到底发生了什么?在我的系统中运行脚本时,使用上面的代码,即使在我同事的笔记本电脑中,它也能非常清晰地从网页中裁剪出图形。我已经开发了触发这个脚本的UI。所以我把它部署在远程windows机器上,那里的裁剪并不像预期的那样。这意味着它有时在上下移动,但左右位置与预期一致。
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