import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
public class AppiumBasics {
@Test
public void appiumTest() throws MalformedURLException {
// we need the code to start the server, then it will perform all the operations and stop the server.
File appiumJS = new File("npm//node_modules//appium//build//lib//main.js");
// Configure and start the Appium service
AppiumDriverLocalService service = new AppiumServiceBuilder()
.withAppiumJS(appiumJS)
.withIPAddress("127.0.0.1")
.usingPort(4723)
.build();
service.start();
//Define DesiredCapabilities for UIAutomator2
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appium:automationName", "UIAutomator2");
capabilities.setCapability("appium:deviceName", "MobileAutomationMachine"); // Or specify your device name
capabilities.setCapability("appium:app", "D://Appium//resources//ApiDemos-debug.apk"); // Path to the app APK file
// Initialize the Appium driver
AppiumDriver driver = new AndroidDriver(service.getUrl(), capabilities);
// Actual Automation
driver.quit();
service.stop();
}
}
Невозможно запустить сервер Appium с помощью кода, приведенного выше. когда я запускаю сервер вручную и нажимаю приведенный ниже код, он работает правильно.
Ниже приведена ошибка, которую я получаю после попытки запустить сервер Appium через автоматизацию. Ниже я привел всю ошибку и удалил некоторые ненужные ее части.
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
[Appium] Welcome to Appium v2.12.1
[Appium] Non-default server args:
[Appium] { address: '127.0.0.1' }
[Appium] The autodetected Appium home path: C:\Users\ATHAR\.appium
[Appium] Appium REST http interface listener started on http://127.0.0.1:4723
[Appium] No drivers have been installed in C:\Users\ATHAR\.appium. Use the "appium driver" command to install the one(s) you want to use.
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
[HTTP] --> GET /status {}
[AppiumDriver@996d] Calling AppiumDriver.getStatus() with args: []
[AppiumDriver@996d] Responding to client with driver.getStatus() result: {"ready":true,"message":"The server is ready to accept new connections","build":{"version":"2.12.1"}}
[HTTP] POST /session {"capabilities":{"firstMatch":[{"appium:app":"D://Appium//resources//ApiDemos-debug.apk","appium:automationName":"UIAutomator2","appium:deviceName":"MobileAutomationMachine","platformName":"ANDROID"}]}}
[AppiumDriver@996d] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{"appium:app":"D://Appium//resources//ApiDemos-debug.apk","appium:automationName":"UIAutomator2","appium:deviceName":"MobileAutomationMachine","platformName":"ANDROID"}]}]
[AppiumDriver@996d] Event 'newSessionRequested' logged at 1731433345127 (23:12:25 GMT+0530 (India Standard Time))
[Appium] Attempting to find matching driver for automationName 'UIAutomator2' and platformName 'ANDROID'
[AppiumDriver@996d] Event 'newSessionStarted' logged at 1731433345131 (23:12:25 GMT+0530 (India Standard Time))
**[AppiumDriver@996d] Encountered internal error running command: Error: Could not find a driver for automationName 'UIAutomator2' and platformName 'ANDROID'. Have you installed a driver that supports those capabilities? Run 'appium driver list --installed' to see.** (Lower-level error: Could not find installed driver to support given caps)
at DriverConfig.findMatchingDriver
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Could not find a driver for automationName 'UIAutomator2' and platformName 'ANDROID'. Have you installed a driver that supports those capabilities? Run 'appium driver list --installed' to see. (Lower-level error: Could not find installed driver to support given caps)
Host info: host: 'DESKTOP-LGNE5KF', ip: '192.168.0.105'
Build info: version: '4.26.0', revision: '8ccf0219d7'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.10'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[Capabilities {appium:app: D://Appium//resources//ApiD..., appium:automationName: UIAutomator2, appium:deviceName: MobileAutomationMachine, platformName: ANDROID}]}]
Capabilities {appium:app: D://Appium//resources//ApiD..., appium:automationName: UIAutomator2, appium:deviceName: MobileAutomationMachine, platformName: ANDROID}
Кто-нибудь может помочь с вышеуказанной проблемой. Я застрял в этом.
@Test public void appiumTest() throws MalformedURLException {
// we need the code to start the server, then it will perform all the operations and stop the server. File appiumJS = new File("npm//node_modules//appium//build//lib//main.js");
// Configure and start the Appium service AppiumDriverLocalService service = new AppiumServiceBuilder() .withAppiumJS(appiumJS) .withIPAddress("127.0.0.1") .usingPort(4723) .build();
service.start();
//Define DesiredCapabilities for UIAutomator2 DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("appium:automationName", "UIAutomator2"); capabilities.setCapability("appium:deviceName", "MobileAutomationMachine"); // Or specify your device name capabilities.setCapability("appium:app", "D://Appium//resources//ApiDemos-debug.apk"); // Path to the app APK file
// Initialize the Appium driver AppiumDriver driver = new AndroidDriver(service.getUrl(), capabilities); // Actual Automation
driver.quit(); service.stop(); } } [/code] Невозможно запустить сервер Appium с помощью кода, приведенного выше. когда я запускаю сервер вручную и нажимаю приведенный ниже код, он работает правильно. Ниже приведена ошибка, которую я получаю после попытки запустить сервер Appium через автоматизацию. Ниже я привел всю ошибку и удалил некоторые ненужные ее части. [code]SLF4J(W): No SLF4J providers were found. SLF4J(W): Defaulting to no-operation (NOP) logger implementation SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details. [Appium] Welcome to Appium v2.12.1 [Appium] Non-default server args: [Appium] { address: '127.0.0.1' } [Appium] The autodetected Appium home path: C:\Users\ATHAR\.appium [Appium] Appium REST http interface listener started on http://127.0.0.1:4723 [Appium] No drivers have been installed in C:\Users\ATHAR\.appium. Use the "appium driver" command to install the one(s) you want to use. [Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. [HTTP] --> GET /status {} [AppiumDriver@996d] Calling AppiumDriver.getStatus() with args: [] [AppiumDriver@996d] Responding to client with driver.getStatus() result: {"ready":true,"message":"The server is ready to accept new connections","build":{"version":"2.12.1"}} [HTTP] POST /session {"capabilities":{"firstMatch":[{"appium:app":"D://Appium//resources//ApiDemos-debug.apk","appium:automationName":"UIAutomator2","appium:deviceName":"MobileAutomationMachine","platformName":"ANDROID"}]}} [AppiumDriver@996d] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{"appium:app":"D://Appium//resources//ApiDemos-debug.apk","appium:automationName":"UIAutomator2","appium:deviceName":"MobileAutomationMachine","platformName":"ANDROID"}]}] [AppiumDriver@996d] Event 'newSessionRequested' logged at 1731433345127 (23:12:25 GMT+0530 (India Standard Time)) [Appium] Attempting to find matching driver for automationName 'UIAutomator2' and platformName 'ANDROID' [AppiumDriver@996d] Event 'newSessionStarted' logged at 1731433345131 (23:12:25 GMT+0530 (India Standard Time)) **[AppiumDriver@996d] Encountered internal error running command: Error: Could not find a driver for automationName 'UIAutomator2' and platformName 'ANDROID'. Have you installed a driver that supports those capabilities? Run 'appium driver list --installed' to see.** (Lower-level error: Could not find installed driver to support given caps) at DriverConfig.findMatchingDriver
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Could not find a driver for automationName 'UIAutomator2' and platformName 'ANDROID'. Have you installed a driver that supports those capabilities? Run 'appium driver list --installed' to see. (Lower-level error: Could not find installed driver to support given caps) Host info: host: 'DESKTOP-LGNE5KF', ip: '192.168.0.105' Build info: version: '4.26.0', revision: '8ccf0219d7' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.10' Driver info: io.appium.java_client.android.AndroidDriver Command: [null, newSession {capabilities=[Capabilities {appium:app: D://Appium//resources//ApiD..., appium:automationName: UIAutomator2, appium:deviceName: MobileAutomationMachine, platformName: ANDROID}]}] Capabilities {appium:app: D://Appium//resources//ApiD..., appium:automationName: UIAutomator2, appium:deviceName: MobileAutomationMachine, platformName: ANDROID}
[/code] Кто-нибудь может помочь с вышеуказанной проблемой. Я застрял в этом.