Closed dipakkumar1225 closed 2 months ago
The element-wait plugin conflicts with the images plugin. After removing the element-wait plugin from the --use-plugins list, the image element is clicked properly.
public class Main {
private static AppiumDriverLocalService getAppiumDriverService() {
String strDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("MMMM_dd_yyyy"));
String strTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH_mm_ss"));
var strReportDir = Paths.get(System.getProperty("user.dir"), strDate);
String logFileName = String.format("Appium_Server_%s.log", strTime);
File logFile = new File(Paths.get(strReportDir.toString(), logFileName).toString());
return AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingPort(4723)
.withArgument(() -> "--long-stacktrace")
.withArgument(GeneralServerFlag.LOG_LEVEL, "info:debug")
.withArgument(GeneralServerFlag.USE_DRIVERS, "uiautomator2")
.withArgument(GeneralServerFlag.ALLOW_INSECURE, "adb_shell")
.withArgument(GeneralServerFlag.RELAXED_SECURITY)
.withArgument(GeneralServerFlag.USE_PLUGINS, "images, gestures, ocr")//element-wait
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(() -> "--config", new File(System.getProperty("user.dir") + File.separator + "config" + File.separator + "serverconfig.json").toString())
.withTimeout(Duration.ofSeconds(240))
.withLogOutput(System.err)
.withLogFile(logFile));
}
public static void main(String[] args) throws IOException, InterruptedException {
AppiumDriverLocalService appiumDriverLocalService = getAppiumDriverService();
AppiumDriver appiumDriver = null;
try {
appiumDriverLocalService.start();
UiAutomator2Options uiAutomator2Options = new UiAutomator2Options()
.setAutomationName(AutomationName.ANDROID_UIAUTOMATOR2)
.setApp(System.getProperty("user.dir") + File.separator + "app" + File.separator + "android" + File.separator + "mda-2.0.2-23.apk")
.setFullReset(false)
.setNoReset(true)
.setPlatformName("android")
.setPlatformVersion("13")
.setUdid("ZD222CJSXB")
.setAppPackage("com.saucelabs.mydemoapp.android")
.setAppActivity("com.saucelabs.mydemoapp.android.view.activities.SplashActivity");
uiAutomator2Options.setCapability("shouldTerminateApp", true);
System.out.println("URL " + appiumDriverLocalService.getUrl());
appiumDriver = new AndroidDriver(appiumDriverLocalService.getUrl(), uiAutomator2Options);
System.out.println("SessionID " + appiumDriver.getSessionId());
Thread.sleep(5000);
byte[] navMenuByte = FileUtils.readFileToByteArray(new File(System.getProperty("user.dir") + File.separator + "image" + File.separator + "NavMenuIcon.png"));
String navMenuEncodedString = Base64.getEncoder().encodeToString(navMenuByte);
appiumDriver.findElement(AppiumBy.image(navMenuEncodedString)).click();
Thread.sleep(5000);
} finally {
if (appiumDriver != null) {
appiumDriver.quit();
}
appiumDriverLocalService.stop();
}
}
}
Failed Log when element-wait is passed in --use-plugins https://gist.github.com/dipakkumar1225/207e6ce236f3f6bb27abfcfe6ca7ac1f
Success Log when element-wait plugin is not used in --use-plugins https://gist.github.com/dipakkumar1225/c80de443415e7f15fa486cce78d94e08
Please suggest the solution for this
We do not maintain the element-wait plugin. Please report your issue to plugin authors
Description
Not able to click on image locator
installed driver list
installed plugin list
Environment
Details
Please provide more details, if necessary.
Code To Reproduce Issue [ Good To Have ]
Exception Stacktraces
Link To Appium Logs
https://gist.github.com/dipakkumar1225/2997b7c5a1dc7c4bb93c161589eb439f