有什么方法可以使用硒测试画布吗?
例如:
答案 0 :(得分:0)
您可以将Selenium与OpenCV结合使用,如此处所述:
导入示例:
driver = webdriver.Chrome("./chromedriver")
driver.get("http://www.tripletsandus.com/80s/80s_games/html5_galaga.htm")
…
def get_driver_image(driver):
canvas_base64 = driver.execute_script("return
arguments[0].toDataURL('image/png').substring(21);", a)
cap = base64.b64decode(canvas_base64)
global image
global gray_image
image = cv2.imdecode(np.frombuffer(cap, np.uint8), 1)
之后,您可以使用OpenCV做魔术,例如:
https://www.pyimagesearch.com/2016/02/15/determining-object-color-with-opencv/