0

ive got the program that recognizes captcha. And i need in SeleniumBase test do the next steps:

  1. download captcha png, save it somewhere in system folder
  2. run batch file to process downloaded png
  3. result is saved in txt, read the result
import os
from seleniumbase import BaseCase


class captcha():
    os.system("C:\\captcha\\run_captcha.bat" + " 1.png C:\\captcha\\ 1") 


class LoginTest(BaseCase):
    def test_login(self):
        self.open ("url")
        self.save_element_as_image_file("#CaptchaControl1_CaptchaImage", "1", r"C:\\captcha")
        #os.system("C:\\captcha\\run_captcha.bat" + " 1.png C:\\captcha\\ 1") returns INTERNALERROR if called here
        captcha()

but there is the problem: somehow the result of the run_captcha.bat appears before seleniumbase opens the browser and downloads the image how to execute batch after downloading the image?

kGustaw
  • 11
  • 2
  • Rather than trying to solve a captcha, maybe you can bypass it entirely by running seleniumbase in undetected mode with the ``--uc`` option. Example run command: ``pytest --uc``. – Michael Mintz Dec 03 '22 at 05:14
  • We can develop a bypass, but it will cost the project money, plus for the current framework, one enthusiast has already trained a neural network for our captcha, and now I'm thinking of just taking it for the new framework. – kGustaw Dec 05 '22 at 12:54
  • also, we can't implement jwt, and we cant disable captcha on the test environment, because of critical data – kGustaw Dec 05 '22 at 13:33
  • There are several tests here that use `save_element_as_image_file()`: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_image_saving.py – Michael Mintz Dec 05 '22 at 14:21
  • @MichaelMintz thank you for link, but nothing fits, there is no actions with file after saving it. Also just discovered that the result of the run_captcha.bat program appears before opening the browser, performing all the steps of the test and downloading the file, thats why the result is empty – kGustaw Dec 05 '22 at 15:08

0 Answers0