I want compare 2 images.But I am getting below error.
fp.seek(0)
AttributeError: 'WebElement' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\......\test_ImagePreview.py", line
107, in test_PlaylistExport
imCompare2 = Image.open(driver.find_element_by_xpath("xhtml:html/xhtml:body/xhtml:img"))
File "C:\Python34\lib\site-packages\PIL\Image.py", line 2254, in open
fp = io.BytesIO(fp.read())
AttributeError: 'WebElement' object has no attribute 'read'
1st image is stored in my computer and second image is from the webpage.
Script I'm using:
imCompare1 = Image_Path
imCompare2 = Image.open(driver.find_element_by_xpath("xhtml:html/xhtml:body/xhtml:img"))
Comparediff = ImageChops.difference(imCompare1, imCompare2).getbbox()
print (Comparediff)
from DOM:< xhtml:img src="https://XXX.XX.XXX.XXX/Path1/Path2/Files.aspx?method=getPreview&fileid=5959&session=hddkdcgywtdw025u4ikiljk0" alt="ttps://XXX.XX.XXX.XXX/Path1/Path2/Files.aspx?method=getPreview&fileid=5959&session=hddkdcgywtdw025u4ikiljk0/ >
Can someone tell me what Am I doing wrong? As its in Xhtml. How I can compare images from webpage?