Unable to launch Avd when integrating appium with jenkins
See original GitHub issueThe problem
Unable to launch AVD when integrating appium test with jenkins, appium session is starting programatically
Environment
- Appium version 1.15.1
- Last Appium version that did not exhibit the issue (if applicable): N/A
- Desktop OS/version used to run Appium: Window 10
- Node.js version (unless using Appium.app|exe): 12.14.1
- Npm or Yarn package manager: 6.13.6
- Mobile platform/version under test: android
- Real device or emulator/simulator: emulator
- Appium CLI or Appium.app|exe: CLI
Details
I’m integrating appium with Jenkins trying to execute mobile automation test running against emulator, everything is working fine locally but with Jenkins, it’s not, however, when I’m running same test but running appium manually from CLI , test executed fine with Jenkins
Link to Appium logs
`[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver] "alwaysMatch": {
[debug] [BaseDriver] "platformName": "android",
[debug] [BaseDriver] "appium:app": "C:\\Program Files (x86)\\Jenkins\\workspace\\SafeApp- MobileAutomationFrameWork\\src\\main\\resources\\Safe.apk",
[debug] [BaseDriver] "appium:appActivity": "com.trackerproducts.mobile.MainActivity",
[debug] [BaseDriver] "appium:appPackage": "com.trackerproducts.mobile",
[debug] [BaseDriver] "appium:autoGrantPermissions": true,
[debug] [BaseDriver] "appium:automationName": "uiautomator2",
[debug] [BaseDriver] "appium:avd": "Pixel",
[debug] [BaseDriver] "appium:avdLaunchTimeout": 15000,
[debug] [BaseDriver] "appium:clearSystemFiles": true,
[debug] [BaseDriver] "appium:deviceName": "emulator-5554",
[debug] [BaseDriver] "appium:nativeWebScreenshot": true,
[debug] [BaseDriver] "appium:platformVersion": "10"
[debug] [BaseDriver] },
[debug] [BaseDriver] "firstMatch": [
[debug] [BaseDriver] {}
[debug] [BaseDriver] ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 2545be3c-1361-4c8d-96ca-0c508aa4035d
[BaseDriver] Using local app 'C:\Program Files (x86)\Jenkins\workspace\SafeApp- MobileAutomationFrameWork\src\main\resources\Safe.apk'
[debug] [UiAutomator2] Checking whether app is actually present
[ADB] Found 3 'build-tools' folders under 'C:\users\warrior\appData\local\Android\Sdk' (newest first):
[ADB] C:/users/warrior/appData/local/Android/Sdk/build-tools/29.0.3
[ADB] C:/users/warrior/appData/local/Android/Sdk/build-tools/29.0.2
[ADB] C:/users/warrior/appData/local/Android/Sdk/build-tools/28.0.3
[ADB] Using 'adb.exe' from 'C:\users\warrior\appData\local\Android\Sdk\platform-tools\adb.exe'
[debug] [ADB] Trying to find 'Pixel' emulator
[debug] [ADB] Getting connected emulators
[debug] [ADB] Getting connected devices...
[debug] [ADB] No connected devices have been detected
[debug] [ADB] 0 emulator(s) connected
[debug] [ADB] Emulator 'Pixel' not running
[debug] [ADB] Launching Emulator with AVD Pixel, launchTimeout 15000ms and readyTimeout 60000ms
[ADB] Using 'emulator.exe' from 'C:\users\warrior\appData\local\Android\Sdk\emulator\emulator.exe'
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1584569044394 (23:04:04 GMT+0100 (Central European Standard Time))
[debug] [W3C] Encountered internal error running command: Error: Avd 'Pixel' is not available. please select your avd name from one of these: '()'
[debug] [W3C] at ADB.checkAvdExist (C:\Users\warrior\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:802:11)
[debug] [W3C] at ADB.launchAVD (C:\Users\warrior\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:695:3)
[debug] [W3C] at Object.prepareEmulator (C:\Users\warrior\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:127:3)
[debug] [W3C] at Object.getDeviceInfoFromCaps (C:\Users\warrior\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:189:5)
[debug] [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (C:\Users\warrior\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:286:26)
[debug] [W3C] at AndroidUiautomator2Driver.createSession (C:\Users\warrior\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:208:7)
[debug] [W3C] at AppiumDriver.createSession (C:\Users\warrior\AppData\Roaming\npm\node_modules\appium\lib\appium.js:358:35)
[HTTP] <-- POST /wd/hub/session 500 293 ms - 727
[HTTP]
Starting test suite for Adding Case Functionality Test Cases
`
Code To Reproduce Issue [ Good To Have ]
` private void createAppiumInstance() {
service = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File("C:\\Program Files\\nodejs\\node.exe"))
.withAppiumJS(new File("C:\\Users\\warrior\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js"))
.usingAnyFreePort()
.withArgument(AppiumArgs.ALLOWINSECURE, "adb_shell"));
service.start();
}
@BeforeSuite(alwaysRun = true)
@Parameters({"deviceName","platformName","platformVersion","avd","automationName","URL_","port"})
public void setUp (String deviceName, String platformName, String platformVersion, String avd, String automationName, String URL_, String port) throws MalformedURLException, InterruptedException {
System.out.println("==> Driver Is Initiating <==");
DesiredCapabilities dc = new DesiredCapabilities();
// Mobile Config Setup
dc.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
dc.setCapability("platformName",platformName);
dc.setCapability("platformVersion",platformVersion);
dc.setCapability("avd",avd);
dc.setCapability("avdLaunchTimeout",15000);
dc.setCapability("avdReadyTimeout",15000);
dc.setCapability(MobileCapabilityType.AUTOMATION_NAME,automationName);
// dc.setCapability("isHeadless",true);
//Application Config Setup
dc.setCapability(MobileCapabilityType.APP, new File("src/main/resources/Test.apk").getAbsolutePath());
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,"com.trest.mobile");
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,"com.trtests.mobile.MainActivity");
dc.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS,true);
dc.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES,true);
// dc.setCapability("showGradleLog",true);
dc.setCapability(AndroidMobileCapabilityType.NATIVE_WEB_SCREENSHOT,true);
createAppiumInstance();
// driver = new AndroidDriver(new URL("http://"+URL_+":"+port+"/wd/hub"),dc);
driver = new AndroidDriver(service.getUrl(),dc);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Map<String, Object> firstArgs = new HashMap<>();
Map<String, Object> SecondArgs = new HashMap<>();
Map<String, Object> ThirdArgs = new HashMap<>();
firstArgs.put("command", "settings");
SecondArgs.put("command", "settings");
ThirdArgs.put("command", "settings");
firstArgs.put("args", Lists.newArrayList("put global window_animation_scale 0.0"));
SecondArgs.put("args", Lists.newArrayList("put global animator_duration_scale 0.0"));
ThirdArgs.put("args", Lists.newArrayList("put global transition_animation_scale 0.0"));
driver.executeScript("mobile: shell", firstArgs);
driver.executeScript("mobile: shell", SecondArgs);
driver.executeScript("mobile: shell", ThirdArgs);
LoginPage start = new LoginPage();
start.createPentestDomain();
//driver.startRecordingScreen();
}
`
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Appium integration with Jenkins - Support
Hi,. I have this maven project that automates my android and iOS app using appium. However now, I want to integrate my project...
Read more >Unable to launch Appium tests from Jenkins - Support
Im trying to launch my Appium tests from Jenkins. It's working great when i: Starting Appium server manually (cmd.exe Appium) Launch tests from...
Read more >Running android emulator in jenkins throws error :FATAL
Hi Guys, Requesting to help me in configuring android emulator in jenkins. I'm new to Jenkins and i'm facing difficulty. Details:
Read more >Unable to start appium through Jenkins programatically ...
find in jenkins job logs place where the job starting. · identify under what user starting jenkins job · after 1+2 -> navigate...
Read more >Emulator:Error getting device platform version - Jenkins Jira
The emulator created successfully and appium services started. Appium detects the device also. ... However i get following error when adb tries to ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does the machine has
Pixel
named emulator instance? If the Jenkins machine does not support x86 architecture, the emulator is very slow. 15s timeout is not enough, I believe.disableWindowAnimation
capability works as same asput global window_animation_scale 0.0
, btw.Closed as not an issue