Find function isn´t find images

Find is not finding the images on the screen. I’ve already tested with several different images and none of them work

desktop_bot.type_keys([“win”, “d”])

my find:
if not self.find(“pasta”, matching=0.97, waiting_time=10000):


Element not found: pasta
Traceback (most recent call last):
File “/mnt/linux/trabalho/scrapy-tim/buscar_nome_telefone_por_cep/buscar_nome_telefone_por_cep/”, line 41, in
File “/mnt/linux/trabalho/scrapy-tim/.venv/lib/python3.10/site-packages/botcity/base/”, line 142, in main
File “/mnt/linux/trabalho/scrapy-tim/buscar_nome_telefone_por_cep/buscar_nome_telefone_por_cep/”, line 27, in action
File “/mnt/linux/trabalho/scrapy-tim/.venv/lib/python3.10/site-packages/botcity/base/”, line 45, in wrapper
raise ValueError(f’Element not available. Cannot invoke {}.')
ValueError: Element not available. Cannot invoke move.

Hi @leandro23!

What is the structure of your project?

In the code, you are using “desktop_bot” to press the keys, but you are using “self” when doing the find.

Is the “self” also referencing a DesktopBot instance? Could you send me the complete code, please?

Hi @joaovoltarelli ! Thanks for listening.

The project structure was generated by cookiecutter for desktop and web applications (option 3)

You've downloaded /home/leandro/.cookiecutters/bot-python-template before. Is it okay to delete and re-download it? [yes]: yes
Select project_type:
1 - Desktop
2 - Web
3 - Both
4 - Custom

This is the content of file

from botcity.core import DesktopBot
from botcity.web import WebBot, Browser
from dotenv import load_dotenv

# from os import environ


class Bot(WebBot):
    def action(self, execution=None):
        self.headless = False
        desktop_bot = DesktopBot()
        # self.browser = Browser.CHROME

        # self.driver_path = "<path to your WebDriver binary>"
        # caminho_driver = environ["CAMINHO_CHROMEDRIVER"]
        # self.driver_path = caminho_driver
        # self.browse("")
        desktop_bot.type_keys(["win", "d"])

        if not self.find(
        # Stop the browser and clean up
        # self.wait(5000)
        # self.stop_browser()

    def not_found(self, label):
        print(f"Element not found: {label}")

if __name__ == "__main__":

Using desktop_bot to find the image i got the same error.

From here I don’t know if it’s related to my problem.

I tried to create a bot version using pyautogui and I got a similar error. I solved this problem in the pyautogui application by setting confidence to 0.7 and installing opencv-python.

img = pyautogui.locateCenterOnScreen(
    path, confidence=0.7, grayscale=False

I tried to install opencv-python in the botcity application and set matching=0.7 but got the same error

        if not self.find(

@leandro23 I think I found the problem,

class Bot(WebBot) is referencing a WebBot, so when you use “self”, you are referencing a WebBot, but the WebBot only has access to the browser context, so it does not find the element that is outside the browser context.

In this case, you can switch from “self” to “desktop_bot”, when performing operations with the DesktopBot instance


desktop_bot.type_keys(["win", "d"])

if not desktop_bot.find("pasta", matching=0.97, waiting_time=5000):


Basically, just remember to use “desktop_bot” for desktop operations and use “self” when you want to perform web browser operations.