botcity-dev / botcity-framework-web-python

BotCity Framework Web - Python
https://documentation.botcity.dev/frameworks/web/
Apache License 2.0
40 stars 19 forks source link

TypeError: locate_all_opencv() missing 1 required positional argument: 'haystack_image' #29

Closed lf2a closed 2 years ago

lf2a commented 2 years ago

Describe the bug Error when get_element_coords() is called. https://github.com/botcity-dev/botcity-framework-web-python/blob/1b7d79faa907faaebd3682c4c82f082899c69278/botcity/web/bot.py#L767

Expected behavior Get coords.

Steps to Reproduce

import os

from botcity.web import WebBot, Browser, By

project_path = os.path.abspath('')

web = WebBot()
web.headless = False
web.browser = Browser.FIREFOX
web.driver_path = os.path.join(project_path, 'web-drivers', 'geckodriver.exe')

web.browse('https://google.com')

try:
    web.add_image('google', os.path.join('resources', 'google-logo.png'))
    web.get_element_coords('google')
finally:
    web.stop_browser()
Traceback (most recent call last):
  File "D:\BotCity\dev\web-test\web.py", line 22, in <module>
    web.get_element_coords('git')
  File "D:\BotCity\dev\web-test\venv\lib\site-packages\botcity\web\bot.py", line 743, in get_element_coords
    it = cv2find.locate_all_opencv(self.state.map_images[label], region=region, confidence=matching)
TypeError: locate_all_opencv() missing 1 required positional argument: 'haystack_image'

Process finished with exit code 1

Possible Solution Add haystack = self.get_screen_image() and change cv2find.locate_all_opencv(self.state.map_images[label], region=region, confidence=matching) to cv2find.locate_all_opencv(self.state.map_images[label], haystack_image=haystack, region=region, confidence=matching)

haystack = self.get_screen_image()
it = cv2find.locate_all_opencv(self.state.map_images[label], haystack_image=haystack, region=region, confidence=matching)

My Platform

hhslepicka commented 2 years ago

Closed via #32