OpenCV and Tesseract can be associated with Artificial Intelligence due to their involvement in tasks that often fall under the AI umbrella, such as computer vision and text recognition. To automate solving image CAPTCHAs using Java, you will typically need several dependencies for tasks such as image processing, machine learning, and possibly computer vision.
OpenCV: A powerful library for computer vision and image processing. You can use the Java bindings for OpenCV.
Tesseract OCR: Tesseract OCR is an optical character recognition library that extracts text from images.
First, add the necessary dependencies to your pom.xml file:
Create a Java class to preprocess the CAPTCHA image and extract the text using Tesseract.
You must create your Tesseract data files and place them in a project directory (e.g., tessdata). but you do need at least the data file for the language used in the CAPTCHA. Tesseract uses trained data files (often referred to as “language data” or “Tessdata”) to recognize text in different languages.
For example, you only need the English-trained data file if your CAPTCHA contains English text. If contains text in another language, you’ll need the corresponding trained data file.
Ensure you have an image CAPTCHA in your project directory(e.g.,captcha//captcha.png) and adjust the paths in the code accordingly.
Then, run the CaptchaSolver class.
By running this code, you should be able to automate the solving of simple image CAPTCHAs. Adjust the preprocessing steps as necessary for more complex CAPTCHAs.
Referring to OpenCV and Tesseract as components of an “AI toolkit” accurately reflects their roles in enabling and enhancing AI applications, particularly in the domains of computer vision and text recognition. They are essential tools for implementing AI-driven solutions, making them integral parts of the AI development ecosystem.
]]>As we learned in the last blog, how to set up Appium 2.0 from scratch and install Appium Inspector too. This blog will teach about Appium Inspector’s desired capabilities to start our Android apps. Appium Inspector is part of the Appium 2.0 framework used to inspect elements within mobile applications for automation testing. Appium Inspector enables users to identify elements such as text boxes, buttons, drop-downs, etc., by getting their attributes like ID, class, and paths.
appium [Appium] Welcome to Appium v2.0.1 [Appium] Attempting to load driver uiautomator2... [debug] [Appium] Requiring driver at C:\Users\ASUS\.appium\node_modules\appium-uiautomator2-driver [Appium] Appium REST http interface listener started on http://0.0.0.0:4723 [Appium] You can provide the following URLS in your client code to connect to this server: [Appium] http://192.168.1.3:4723/ [Appium] http://127.0.0.1:4723/ (only accessible from the same host)
$ adb devices List of devices attached emulator-5554 device
$ adb shell getprop ro.build.version.release 14
$ adb devices List of devices attached emulator-5554 device
See, our APK app is successfully up and running.
This blog should help users set up desired capabilities under Appium Inspector to launch Android apps. We can find locators (xpaths, ID, class name) and it is easier to locate app components such as textbox, button, dropdown, etc. You can select individual elements in the app by clicking on them by inspector. It is part of the Appium 2.0 framework to inspect elements within mobile applications for automation testing. In the next blog, we will create one project and automate apk app.
]]>In this blog, we will set up Appium plugins, Appium drivers, Appium Doctor, NodeJS, UI Automator, Appium inspector, and Android Studio to create our automation scripts for Android devices. Appium 2.0 is an Android platform tool where drivers and plugins are easily created. It will allow us to cover mobile applications, desktop Apps, and Flutter Apps.
Independent Drivers: Ability to install and work with WebDrivers based on your application platform (IOS, Android, Windows OS, Flutter).
Appium 2.0 Plugins: A few Appium plugins are available such as Images, Gestures, Wait, Reporter, and Execute-Driver.
It will no longer support the old JSONWP and MJSONWP Protocols. Only W3C WebDriver protocols are supported. By default, the Appium server runs at http://127.0.0.1:4723/.
Environment variables are used to configure your app data to decrease the chances of unexpected errors and bugs.
npm i -g appium@next
appium -v 2.0.1
appium [Appium] Welcome to Appium v2.0.1 [Appium] Attempting to load driver uiautomator2... [debug] [Appium] Requiring driver at C:\Users\ASUS\.appium\node_modules\appium-uiautomator2-driver [Appium] Appium REST http interface listener started on http://0.0.0.0:4723 [Appium] You can provide the following URLS in your client code to connect to this server: [Appium] http://192.168.1.3:4723/ [Appium] http://127.0.0.1:4723/ (only accessible from the same host)
appium driver list - Listing available drivers √ Listing available drivers - uiautomator2@2.43.3 [not installed] - xcuitest [not installed] - mac2 [not installed] - espresso [not installed] - safari [not installed] - gecko [not installed] - chromium [not installed]
appium driver install uiautomator2
$ appium driver list --updates - Listing available drivers √ Listing available drivers - uiautomator2@2.43.3 [installed (npm)] [Up to date] - xcuitest [not installed] - mac2 [not installed] - espresso [not installed] - safari [not installed] - gecko [not installed] - chromium [not installed]
npm install -g appium-doctor
appium-doctor --version 1.16.2
appium-doctor --android WARN AppiumDoctor [Deprecated] Please use appium-doctor installed with "npm install @appium/doctor --location=global" info AppiumDoctor Appium Doctor v.1.16.2 info AppiumDoctor ### Diagnostic for necessary dependencies starting ### info AppiumDoctorThe Node.js binary was found at: C:\Program Files\nodejs\node.EXE info AppiumDoctor
Node version is 20.11.0 info AppiumDoctor
ANDROID_HOME is set to: C:\Users\ASUS\AppData\Local\Android\Sdk info AppiumDoctor
JAVA_HOME is set to: C:\Program Files\Java\jdk-21.0.1 info AppiumDoctor Checking adb, android, emulator, apkanalyzer.bat info AppiumDoctor 'adb' is in C:\Users\ASUS\AppData\Local\Android\Sdk\platform-tools\adb.exe info AppiumDoctor 'android' is in C:\Users\ASUS\AppData\Local\Android\Sdk\tools\android.bat info AppiumDoctor 'emulator' is in C:\Users\ASUS\AppData\Local\Android\Sdk\emulator\emulator.exe info AppiumDoctor 'apkanalyzer.bat' is in C:\Users\ASUS\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\apkanalyzer.bat info AppiumDoctor
adb, android, emulator, apkanalyzer.bat exist: C:\Users\ASUS\AppData\Local\Android\Sdk info AppiumDoctor
'bin' subfolder exists under 'C:\Program Files\Java\jdk-21.0.1'
$ appium plugin list - Listing available plugins √ Listing available plugins - images [not installed] - execute-driver [not installed] - relaxed-caps [not installed] - universal-xml [not installed]
$ appium plugin install images - Installing 'images' using NPM install spec '@appium/images-plugin' √ Installing 'images' using NPM install spec '@appium/images-plugin' i Plugin images@3.0.1 successfully installed
$ adb devices List of devices attached emulator-5554 device
Appium 2.0 is now successfully installed on your system!
This blog should help users install and set up Appium 2.0 smoothly on their system. The main purpose of Appium 2.0 is to make the test automation process more modular and flexible. This includes transitioning to a new architecture for extensions and drivers. It will no longer support the old JSONWP and MJSONWP Protocols. Only W3C Webdriver protocols are supported. By default, the Appium server runs at http://127.0.0.1:4723/. I hope this blog post was useful in helping your transition to Appium 2.0.
]]>