I have a problem every thing is right configured here my code :
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Newlook_1 {
AndroidDriver<AndroidElement> driver;
File path = new File(
"/home/emna/Téléchargements/AutomationFiles/app-debug.apk");
@BeforeClass
public void setUp() throws MalformedURLException {
System.out.println("app Dir.--->" + path);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "SM-G531H");
capabilities.setCapability("version", "5.1.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("device", "Android");
capabilities.setCapability("platformVersion", "platform");
capabilities.setCapability("udid", "***********");
capabilities.setCapability("app", path.getAbsolutePath());
capabilities.setCapability("appPackage", "com.bulldozer.newlook");
capabilities.setCapability("appActivity", "com.bulldozer.newlook.activities.SplashActivity");
capabilities.setCapability("noReset", "false");
driver = new AndroidDriver<AndroidElement>(new URL(
"http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(1500, TimeUnit.SECONDS);
}
@Test
public void Test1() throws InterruptedException {
driver.wait(10000);
System.out.println("newlook-tutoriel");
driver.findElement(By.id("skip")).click();
System.out.println("newlook-welcome");
driver.wait(1000);
driver.findElement(By.id("btn_signin_welcome")).click();
System.out.println("newlook-Me connecter");
driver.findElement(By.id("input_email")).sendKeys("e@e.emmna.com");
driver.findElement(By.id("input_password")).sendKeys("00000000");
}
@AfterClass
public void tearDown() {
driver.quit();
}
}
while i run appium with npm using :
appium -a 127.0.0.1
It looks like the application start after a while it get crashed !
Here my appium log file it tells that there is a IllegalMonitorStateException in java add to that :
[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","********","shell","am","force-stop","com.bulldozer.newlook"]
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","************","shell","input","keyevent",3]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 12.803
[debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","******","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","4b13731fdfdd824e","shell","am","force-stop","io.appium.unlock"]
[debug] [Logcat] Stopping logcat capture
[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[Appium] Removing session 7fe5b58a-8d00-4f8a-9aa8-f61f2d374eb6 from our master session list
[debug] [MJSONWP] Received response: null
[debug] [MJSONWP] But deleting session, so not returning
[debug] [MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/7fe5b58a-8d00-4f8a-9aa8-f61f2d374eb6 200 2319 ms - 76
How can i solve this problem? shall i restart the remote session ? Thanks in advance for any solution you propose :)
I am facing the same problem. However, it doesn't happen with all the devices.
The workaround which I am using :
You can try this
I solve it just by removing :
driver.wait(10000);