from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
driver = webdriver.Chrome('chromedriver.exe')
driver.get('http://typingx0.net/pop/')
driver.set_window_size(600,500)
input()
fname = "test.png"
driver.save_screenshot(fname)
import sys
import cv2
import pyocr
import numpy as np
from PIL import Image
image = "test.png"
name = "test"
img = cv2.imread(image)
cv2.imwrite(f"1_{name}_original.png",img)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imwrite(f"2_{name}_gray.png",img)
th = 140
img = cv2.threshold(
img
, th
, 255
, cv2.THRESH_BINARY
)[1]
cv2.imwrite(f"3_{name}threshold{th}.png",img)
img = cv2.bitwise_not(img)
cv2.imwrite(f"4_{name}_bitwise.png",img)
cv2.imwrite("target.png",img)
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
tool = tools[0]
res = tool.image_to_string(
Image.open("target.png")
,lang="eng")
print(res)
element.send_keys(res)
このプログラムはpyocrで認識した文字を入力したいのですが element.send_keys でエラーが出てしまいます