self.find() stops do find the image (that it already has founded before) from nothing. Sometimes I want to take another picture of the same image, and it still not work. It just stops to detect that image, forever. Someone can help?
This problem can be caused by several reasons, such as changes in the look of the element being searched for on the screen or even resolution settings, for example.
Could you send information about the code you are trying to use and the page used in the automation, please?
Hi!
I’m facing the same problem. The application works fine for a certain time, but suddenly stops to recognize some images. It happens both locally and in prod environments.
When running locally, i can see the browser with the information needed already loaded, but even after that the application fails to recognize the elements.
I’m trying to access this page: eCAC - Centro Virtual de Atendimento
The code is something like this:
if not self.__get_element(label="cpf", waiting_time=self.default_waiting_time):
return self.__not_found("Não foi possível encontrar o elemento 'cpf'")
Thanks!
@Diego.Pereira What do you have for your __get_element function? Did you write a wrapper for the find command?
Sorry, i forgot to paste the wrapper function.
def __get_element(self, label, matching: float = 0.6, waiting_time=2000):
start_time = time.time()
while True:
elapsed_time = (time.time() - start_time) * 1000
if elapsed_time > waiting_time:
return None
ele = self.find(label=label, matching=matching, waiting_time = waiting_time)
if ele is not None:
return ele```
The __get_element wrapper is redundant as the self.find already takes care of the waiting time.
The way you implemented it, your loop will run only once as you are passing the waiting_time to the find function.
Could you please try to run just with the call to find and see how that goes?
It often helps to debug to take a screenshot of the element is not found and inspect why the field was not there. eCAC is a portal with many common issues of rendering like that.
Try to do a test and call self.save_screenshot(“debug.png”) and look into the image if the cpf is not found. This will bring you some insights.
I removed the redundant code and took a screenshot via self.save_screenshot(“debug.png”).
The element is on the screen.
Here’s the code
# if not self.__get_element(label="cpf", waiting_time=self.default_waiting_time):
if not self.find(label="cpf", matching=0.8):
self.save_screenshot(r"C:\Users\debug.png")
return self.__not_found("Não foi possível encontrar o elemento 'cpf'")
Here’s the screenshot
Thanks for the quick answers!
Could you upload here the cpf
image that you are using for the search?
Sure! Here it is.