This script used to run before the 31th of August. But it shows these three errors now.
I have tried uninstall the pillow, or use the particular version, but it still not work,like this : Pyautogui screenshot - NameError: name 'Image' is not defined
Does anyone have idea on this ?
"EC" is not defined, "array" is not defined, "Image" is not defined
These are relative 2 function.
from selenium import webdriver
from HTMLTestRunner import HTMLTestRunner
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
import array
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
import unittest, time, re, os, sys
import pyautogui
def located_element(self, locator):
wait = WebDriverWait(self.driver,30)
element = wait.until(EC.presence_of_element_located((locator)))
return element
def getClippedImage(driver, canvas, x, y, w, h):
### Get a clipped image from canvas using context.getImageData.
data = driver.execute_script(
"var canvas= arguments[0];
var x=arguments[1];
var y=arguments[2];
var w=arguments[3];
var h=arguments[4];
var context = canvas.getContext(‘2d‘);
var dataObj= context.getImageData(x, y, w, h);
var data = dataObj.data;
return data;"
,canvas, x, y, w, h)
data_bytes = array.array('B', data).tostring()
im = Image.fromstring("RGBA", (w, h), data_bytes)
return im