selenium 未定义EC、未定义数组、未定义图像

uqjltbpv  于 2022-11-10  发布在  其他
关注(0)|答案(1)|浏览(309)

此脚本过去在8月31日之前运行。但现在它显示了这三个错误。
我试过卸载枕头,或者使用特定版本,但仍然不起作用,如下所示:Pyautogui screenshot - NameError: name 'Image' is not defined
有谁知道这件事吗?
未定义EC、未定义数组、未定义图像
这些是相对的2个函数。

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
mzmfm0qo

mzmfm0qo1#

使用以下代码进行注解

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='DraftEditor-editorContainer']/div[@class='notranslate public-DraftEditor-content' and starts-with(@aria-describedby, 'placeholder')]"))).send_keys("type the comment here")

相关问题