Bot não clica em imagem

Hey, good morning. I created this code in PyCharm using Windows 10 64bit, however when it gets to the end shown in the video, it doesn’t click on the image with the name GTA V - LINKS LIST. Do you have any solution for this problem?

Here is the code:

from botcity.core import DesktopBot
import chardet
import codecs
import pyperclip
class Bot(DesktopBot):
def action(self, execution=None):
if not self.find( “ClicaNoIconeDoNavegador”, matching=0.97, waiting_time=10000):
self.not_found(“ClicaNoIconeDoNavegador”)
self.click()
if not self.find( “SinoVermelho”, matching=0.97, waiting_time=10000):
self.not_found(“SinoVermelho”)
self.click()
if not self.find( “VoceVendeuGTA5”, matching=0.97, waiting_time=10000):
self.not_found(“VoceVendeuGTA5”)
self.click()
if not self.find( “VerMensagem”, matching=0.97, waiting_time=10000):
self.not_found(“VerMensagem”)
self.click()
if not self.find( “CampoDeMensagemSelecionado”, matching=0.97, waiting_time=10000):
self.not_found(“CampoDeMensagemSelecionado”)
self.click_relative(125, 9)
with open(f’C:\Users\Rafael\Desktop\MercadoLivre\ArquivosDeTexto\mensagens.txt’, ‘rb’) as f:
codificacao = chardet.detect(f.read())[‘encoding’]
with codecs.open(‘C:\Users\Rafael\Desktop\MercadoLivre\ArquivosDeTexto\mensagens.txt’, ‘r’, encoding=codificacao) as f:
texto = f.read()
pyperclip.copy(texto)
self.paste()
if not self.find( “CliqueNoClip”, matching=0.97, waiting_time=10000):
self.not_found(“CliqueNoClip”)
self.click()
if not self.find( “ClicaNoCampoDeDiretorios”, matching=0.97, waiting_time=10000):
self.not_found(“ClicaNoCampoDeDiretorios”)
self.click_relative(436, 16)

    self.paste('C:\\Users\\Rafael\\Desktop\\MercadoLivre\\GTAV')
    self.enter()
    self.wait(2000)
    
    if not self.find( "teste2", matching=0.97, waiting_time=10000):
        self.not_found("teste2")
    self.click()
         
    self.wait(2000)
    self.double_click()
@staticmethod
def not_found(label):
    print(f"Element not found: {label}")

if name == ‘main’:
Bot.main()

I will send you a video of the program running.

Hey @Rafael,

Could you send the error message that is being thrown?

I will send you a video of the running program.

C:\Users\Rafael\PycharmProjects\MercadoLive\venv\Scripts\python.exe C:\Users\Rafael\PycharmProjects\MercadoLive\ML_A\ML_A\bot.py
Element not found: ClicaNoCampoDeDiretorios
Traceback (most recent call last):
File “C:\Users\Rafael\PycharmProjects\MercadoLive\ML_A\ML_A\bot.py”, line 49, in
Bot.main()
File “C:\Users\Rafael\PycharmProjects\MercadoLive\venv\lib\site-packages\botcity\base\bot.py”, line 189, in main
bot.action(execution)
File “C:\Users\Rafael\PycharmProjects\MercadoLive\ML_A\ML_A\bot.py”, line 33, in action
self.click_relative(436, 16)
File “C:\Users\Rafael\PycharmProjects\MercadoLive\venv\lib\site-packages\botcity\base\utils.py”, line 45, in wrapper
raise ValueError(f’Element not available. Cannot invoke {func.name}.')
ValueError: Element not available. Cannot invoke click_relative.

Process finished with exit code 1

Here is the video: 2023 04 19 09 56 41 - YouTube

@Rafael which element are you looking for with this label “ClicaNoCampoDeDiretorios”?

I imagine the intention is to click on the field to enter the path, right?

Have you tried using the “Nome” anchor that appears next to the field? This could be an alternative

1 Like

It is this line that does not work marked in blue:
Uploading: Captura de Tela (914).png…

I have no way to use the text, because the place to insert the message supports a limited amount of characters I can’t use the text, because the place to insert the message supports a limited amount of characters but accepts sending txt files with almost unlimited amount of characters…

@Rafael

my suggestion would be to try to search for this “Nome” element, instead of the folder icon. And then do a relative click on the input to insert the path