Can't run any test. java.lang.ExceptionInInitializerError, Caused by: java.lang.IllegalArgumentException
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.3k
- Forks
- 752
- Avg merge
- 6d 21h
- Merged PRs (30d)
- 8
Description
Every time when I try to run the android test(IOS doesn't try), the test failed with the following errors
java.lang.ExceptionInInitializerError
at com.example.tests.test.CheckWorking.testCheck(CheckWorking.java:10)
Caused by: java.lang.IllegalArgumentException
at com.example.tests.test.CheckWorking.testCheck(CheckWorking.java:10)
Environment
- Appium version 1.15.1
- MacOS 10.14.4
- Node version is 12.3.1
- Npm 6.12.1
- Android 8.1
- Emulator Nexus 6P
Code To Reproduce Issue
TestBase
public class TestBase {
public static AppiumDriver driver;
public static String loadPropertyFileAndroid = "Android.properties";
public static String loadPropertyFileIOS = "properties/iOS.properties";
protected static Example app;
@BeforeSuite
public void setUp() throws IOException {
if (driver == null) {
if (isIOS()) {
CommonUtils.loadIOSConfigProp(loadPropertyFileIOS);
CommonUtils.setIOSCapabilities();
driver = CommonUtils.getIOSDriver();
System.out.print("platform = " + driver.getPlatformName());
// driver.resetApp();
// if (driver.isAppInstalled("com.example.app")) {
// driver.removeApp("com.example.app");
// }
} else if (isAndroid()) {
CommonUtils.loadAndroidConfigProp(loadPropertyFileAndroid);
CommonUtils.setAndroidCapabilities();
driver = CommonUtils.getAndroidDriver();
}
}
if (app == null) {
app = new Example(driver);
}
}
@AfterSuite
public void clearCache(){
driver.resetApp();
}
}
Capabilities
public static void loadAndroidConfigProp(String propertyFileName) throws IOException
{
FileInputStream fis = new FileInputStream(System.getProperty("user.dir") + "/src/main/resources/properties/" + propertyFileName);
prop.load(fis);
EXPLICIT_WAIT_TIME = Integer.parseInt(prop.getProperty("explicit.wait"));
IMPLICIT_WAIT_TIME = Integer.parseInt(prop.getProperty("implicit.wait"));
DEFAULT_WAIT_TIME = Integer.parseInt(prop.getProperty("default.wait"));
APPLICATION_NAME = prop.getProperty("application.path");
BASE_PKG = prop.getProperty("base.pkg");
APP_ACTIVITY = prop.getProperty("application.activity");
APPIUM_PORT = prop.getProperty("appium.server.port");
AUTOMATION_INSTRUMENTATION_APPIUM=prop.getProperty("automation.instrumentation.appium");
AUTOMATION_INSTRUMENTATION_SELENDROID=prop.getProperty("automation.instrumentation.selendroid");
DEVICE_NAME=prop.getProperty("device.name");
BROWSER_NAME=prop.getProperty("browser.name");
PLATFORM_NAME=prop.getProperty("platform.name");
PLATFORM_VERSION=prop.getProperty("platform.version");
NEW_COMMAND_TIMEOUT=prop.getProperty("new.command.timeout");
DEVICE_READY_TIMEOUT=prop.getProperty("device.ready.timeout");
APPIUM_VERSION=prop.getProperty("appium.version");
APP_WAIT_ACTIVITY=prop.getProperty("appWaitActivity");
}
public static void setAndroidCapabilities() {
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, BROWSER_NAME);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, PLATFORM_VERSION);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, DEVICE_NAME);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,AUTOMATION_NAME);
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, NEW_COMMAND_TIMEOUT);
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.APPIUM_VERSION, APPIUM_VERSION);
capabilities.setCapability("appWaitActivity", APP_WAIT_ACTIVITY);
capabilities.setCapability("appActivity", "com.soultime.app.ui.main.ActivityMain");
capabilities.setCapability("autoGrantPermissions", true);
capabilities.setCapability("recreateChromeDriverSessions", true);
capabilities.setCapability("disableAndroidWatchers", true);
capabilities.setCapability("autoGrantPermission", true);
capabilities.setCapability("skipUnlock", true);
capabilities.setCapability("allowTouchIdEnroll", true);
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
capabilities.setCapability(MobileCapabilityType.APP, APPLICATION_NAME);
}
public static AppiumDriver getAndroidDriver() throws MalformedURLException {
serverUrl = new URL("http://localhost:" + APPIUM_PORT + "/wd/hub");
driver = new AndroidDriver(serverUrl, capabilities);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
return driver;
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the stack trace at CheckWorking.java:10 and follow the initialization path through TestBase and CommonUtils, then compare the Android configuration loading and capability setup shown in the report. Reproduce the Android test with the supplied environment and Appium logs; done means identifying and resolving the cause of the initializer failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100