Appium session running on same device in parallel executionRun multiple appium sessions parallel in android deviceappium parallel execution with JsonParallel execution with TestNG and appiumAppium - multiple android devices in parallelParallel runs in appium on real devicesParallel testing on real Android devices using Appiumhow to run script in multiple devices in appiumNot able to run appium on my new android deviceAppium Parallel Test Execution removes driver for one device, showing A session is either terminated or not startedAppium parallel execution on two device issue
Dear Fellow PSE Users,
How to ask a man to not take up more than one seat on public transport while avoiding conflict?
Removing rows containing NA in every column
Twelve Minesweeper mines that make twelve 4s
Madrid to London w/ Expired 90/180 days stay as US citizen
What did the controller say during my approach to land (audio clip)?
Minimize taxes now that I earn more
Algorithm for competing cells of 0s and 1s
Is it safe to unplug a blinking USB drive after 'safely' ejecting it?
Why do we need to use transistors when building an OR gate?
Paradox regarding phase transitions in relativistic systems
The relationship of noch nicht and the passive voice
Is it possible that the shadow of The Moon is a single dot during solar eclipse?
Why is the stock market so unpredictable?
Can one guy with a duplicator initiate a nuclear apocalypse?
Why do things cool down?
Why does Canada require a minimum rate of climb for ultralights of 300 ft/min?
Are lay articles good enough to be the main source of information for PhD research?
Cemented carbide swords - worth it?
How does one calculate the distribution of the Matt Colville way of rolling stats?
Why was Java 8 left out from Debian Buster?
What's the purpose of autocorrelation?
Intuitive methods for representation of Cartesian Coordinates in terms of Spherical Coordinates as basis
What was the deeper meaning of Hermione wanting the cloak?
Appium session running on same device in parallel execution
Run multiple appium sessions parallel in android deviceappium parallel execution with JsonParallel execution with TestNG and appiumAppium - multiple android devices in parallelParallel runs in appium on real devicesParallel testing on real Android devices using Appiumhow to run script in multiple devices in appiumNot able to run appium on my new android deviceAppium Parallel Test Execution removes driver for one device, showing A session is either terminated or not startedAppium parallel execution on two device issue
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to run two different test cases parallelly on two different devices. I am doing following steps to run the test cases :
1) Open two appium server instances using below commands
appium -p 4723 -bp 4724 --chromedriver-port 4725 -U "ZY3223QGDP"
appium -p 4726 -bp 4727 --chromedriver-port 4728 -U "ZY223XJFNS"
I have followed below appium guidelines for starting appium servers :
https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/parallel-tests.md
2) I have created two testng classes to hold both test cases. Below is the code for both the classes and tetng xml file.
3) I am printing appium session in both test cases. For which different values are printed. Even appium logs suggest that both the appium driver are interacting to their respective servers.
In both test I am using different application, but only one test cases pass and one fail. In both test cases I take screenshot which give screenshot of same devices.
Test 1
package com.qklab.register;
import java.io.File;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.testng.annotations.Test;
import com.qk.automation.framework.AppiumManagerTestng;
import io.appium.java_client.AppiumDriver;
public class DeviceOneAppOne
@Test
public void test1(HashMap<String,Object> testDetail) throws Exception
HashMap<String, String> deviceDetails = new HashMap<String, String>();
deviceDetails.put("app_activity","com.hdfc.retail.netbanking.HDFCBank");
deviceDetails.put("app_package","com.snapwork.hdfc");
deviceDetails.put("appium_port","4726");
deviceDetails.put("appium_ip","0.0.0.0");
deviceDetails.put("udid","ZY223XJFNS");
deviceDetails.put("device_name","moto black");
deviceDetails.put("platform_version","8.1.0");
deviceDetails.put("platform_name","Android");
AppiumManagerTestng appiumManager = new AppiumManagerTestng();
AppiumDriver appiumDriver = appiumManager.getAppiumDriverForTestng(deviceDetails);
try
System.out.println("got session id : " + appiumDriver.getSessionId());
//Take screenshot
File srcFile=appiumDriver.getScreenshotAs(OutputType.FILE);
File targetFile=new File("ZY223XJFNS" +".jpg");
System.out.println(targetFile.getAbsolutePath());
FileUtils.copyFile(srcFile,targetFile);
appiumDriver.findElement(By.xpath("//*[@*[contains(.,'SKIP INTRODUCTION')]]")).click();
catch(Exception ex)
throw ex;
2) Test 2
package com.qklab.register;
import java.io.File;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.testng.annotations.Test;
import com.qk.automation.framework.AppiumManagerTestng;
import io.appium.java_client.AppiumDriver;
public class DeviceTwoAppTwo
@Test
public void test2(HashMap<String,Object> testDetail) throws Exception
HashMap<String, String> deviceDetails = new HashMap<String, String>();
deviceDetails.put("app_activity","com.atomyes.MainActivity");
deviceDetails.put("app_package","com.atomyes");
deviceDetails.put("appium_port","4723");
deviceDetails.put("appium_ip","0.0.0.0");
deviceDetails.put("udid","ZY3223QGDP");
deviceDetails.put("device_name","moto silver");
deviceDetails.put("platform_version","7.0");
deviceDetails.put("platform_name","Android");
AppiumManagerTestng appiumManager = new AppiumManagerTestng();
AppiumDriver appiumDriver = appiumManager.getAppiumDriverForTestng(deviceDetails);
try
//Take screenshot
File srcFile=appiumDriver.getScreenshotAs(OutputType.FILE);
File targetFile=new File("ZY3223QGDP" +".jpg");
FileUtils.copyFile(srcFile,targetFile);
appiumDriver.findElement(By.xpath("//*[@text='Skip To Login']")).click();
catch(Exception ex)
Thread.sleep(10000);
throw ex;
3) AppiumDriver generator
package com.qk.automation.framework;
import java.net.URL;
import java.util.HashMap;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
public class AppiumManagerTestng
public AppiumDriver getAppiumDriverForTestng(HashMap<String, String> deviceDetails) throws Exception
AppiumDriver driverForTestng = null;
String app_activity = deviceDetails.get("app_activity");
String app_package = deviceDetails.get("app_package");
String appium_port = deviceDetails.get("appium_port");
String appium_ip = deviceDetails.get("appium_ip");
String udid = deviceDetails.get("udid");
String device_name = deviceDetails.get("device_name");
String platform_version = deviceDetails.get("platform_version");
String platform_name = deviceDetails.get("platform_name");
try
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, device_name);
dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, platform_version);
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, platform_name);
dc.setCapability(MobileCapabilityType.UDID, udid);
dc.setCapability(MobileCapabilityType.NO_RESET, false);
//dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, app_package);
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, app_activity);
driverForTestng = new AppiumDriver(new URL("http://" + appium_ip + ":" + appium_port + "/wd/hub"),dc);
catch(Exception objDriverException)
objDriverException.printStackTrace();
return driverForTestng;
4) Testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests" thread-count="2">
<test name="Test1">
<classes>
<class name="com.qklab.register.DeviceOneAppOne">
<methods>
<include name="test1" />
</methods>
</class>
</classes>
</test>
<test name="Test2">
<classes>
<class name="com.qklab.register.DeviceTwoAppTwo">
<methods>
<include name="test2" />
</methods>
</class>
</classes>
</test>
</suite>
Above code should run both test cases independently of each other. But this is not happening. Any help would be appreciated.
java testng appium appium-android
add a comment
|
I am trying to run two different test cases parallelly on two different devices. I am doing following steps to run the test cases :
1) Open two appium server instances using below commands
appium -p 4723 -bp 4724 --chromedriver-port 4725 -U "ZY3223QGDP"
appium -p 4726 -bp 4727 --chromedriver-port 4728 -U "ZY223XJFNS"
I have followed below appium guidelines for starting appium servers :
https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/parallel-tests.md
2) I have created two testng classes to hold both test cases. Below is the code for both the classes and tetng xml file.
3) I am printing appium session in both test cases. For which different values are printed. Even appium logs suggest that both the appium driver are interacting to their respective servers.
In both test I am using different application, but only one test cases pass and one fail. In both test cases I take screenshot which give screenshot of same devices.
Test 1
package com.qklab.register;
import java.io.File;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.testng.annotations.Test;
import com.qk.automation.framework.AppiumManagerTestng;
import io.appium.java_client.AppiumDriver;
public class DeviceOneAppOne
@Test
public void test1(HashMap<String,Object> testDetail) throws Exception
HashMap<String, String> deviceDetails = new HashMap<String, String>();
deviceDetails.put("app_activity","com.hdfc.retail.netbanking.HDFCBank");
deviceDetails.put("app_package","com.snapwork.hdfc");
deviceDetails.put("appium_port","4726");
deviceDetails.put("appium_ip","0.0.0.0");
deviceDetails.put("udid","ZY223XJFNS");
deviceDetails.put("device_name","moto black");
deviceDetails.put("platform_version","8.1.0");
deviceDetails.put("platform_name","Android");
AppiumManagerTestng appiumManager = new AppiumManagerTestng();
AppiumDriver appiumDriver = appiumManager.getAppiumDriverForTestng(deviceDetails);
try
System.out.println("got session id : " + appiumDriver.getSessionId());
//Take screenshot
File srcFile=appiumDriver.getScreenshotAs(OutputType.FILE);
File targetFile=new File("ZY223XJFNS" +".jpg");
System.out.println(targetFile.getAbsolutePath());
FileUtils.copyFile(srcFile,targetFile);
appiumDriver.findElement(By.xpath("//*[@*[contains(.,'SKIP INTRODUCTION')]]")).click();
catch(Exception ex)
throw ex;
2) Test 2
package com.qklab.register;
import java.io.File;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.testng.annotations.Test;
import com.qk.automation.framework.AppiumManagerTestng;
import io.appium.java_client.AppiumDriver;
public class DeviceTwoAppTwo
@Test
public void test2(HashMap<String,Object> testDetail) throws Exception
HashMap<String, String> deviceDetails = new HashMap<String, String>();
deviceDetails.put("app_activity","com.atomyes.MainActivity");
deviceDetails.put("app_package","com.atomyes");
deviceDetails.put("appium_port","4723");
deviceDetails.put("appium_ip","0.0.0.0");
deviceDetails.put("udid","ZY3223QGDP");
deviceDetails.put("device_name","moto silver");
deviceDetails.put("platform_version","7.0");
deviceDetails.put("platform_name","Android");
AppiumManagerTestng appiumManager = new AppiumManagerTestng();
AppiumDriver appiumDriver = appiumManager.getAppiumDriverForTestng(deviceDetails);
try
//Take screenshot
File srcFile=appiumDriver.getScreenshotAs(OutputType.FILE);
File targetFile=new File("ZY3223QGDP" +".jpg");
FileUtils.copyFile(srcFile,targetFile);
appiumDriver.findElement(By.xpath("//*[@text='Skip To Login']")).click();
catch(Exception ex)
Thread.sleep(10000);
throw ex;
3) AppiumDriver generator
package com.qk.automation.framework;
import java.net.URL;
import java.util.HashMap;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
public class AppiumManagerTestng
public AppiumDriver getAppiumDriverForTestng(HashMap<String, String> deviceDetails) throws Exception
AppiumDriver driverForTestng = null;
String app_activity = deviceDetails.get("app_activity");
String app_package = deviceDetails.get("app_package");
String appium_port = deviceDetails.get("appium_port");
String appium_ip = deviceDetails.get("appium_ip");
String udid = deviceDetails.get("udid");
String device_name = deviceDetails.get("device_name");
String platform_version = deviceDetails.get("platform_version");
String platform_name = deviceDetails.get("platform_name");
try
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, device_name);
dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, platform_version);
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, platform_name);
dc.setCapability(MobileCapabilityType.UDID, udid);
dc.setCapability(MobileCapabilityType.NO_RESET, false);
//dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, app_package);
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, app_activity);
driverForTestng = new AppiumDriver(new URL("http://" + appium_ip + ":" + appium_port + "/wd/hub"),dc);
catch(Exception objDriverException)
objDriverException.printStackTrace();
return driverForTestng;
4) Testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests" thread-count="2">
<test name="Test1">
<classes>
<class name="com.qklab.register.DeviceOneAppOne">
<methods>
<include name="test1" />
</methods>
</class>
</classes>
</test>
<test name="Test2">
<classes>
<class name="com.qklab.register.DeviceTwoAppTwo">
<methods>
<include name="test2" />
</methods>
</class>
</classes>
</test>
</suite>
Above code should run both test cases independently of each other. But this is not happening. Any help would be appreciated.
java testng appium appium-android
Can you please add more details about what is the error that you are seeing? Your code looks threadsafe and I dont see any evident problems in it.
– Krishnan Mahadevan
Mar 29 at 8:48
Curious to know that are these class/tests running at all? Because the test method require one argumentHashMap<String,Object> testDetail
and it is not passed either as parameter or using data-provider. Regardless, While starting appium, instead of using-U
which is deprecated, you can try-dc
or--default-capabilities
. For example:--default-capabilities [ '"app": "myapp.app", "deviceName": "iPhone Simulator"' | /path/to/caps.json ]
.
– user861594
Mar 31 at 4:39
add a comment
|
I am trying to run two different test cases parallelly on two different devices. I am doing following steps to run the test cases :
1) Open two appium server instances using below commands
appium -p 4723 -bp 4724 --chromedriver-port 4725 -U "ZY3223QGDP"
appium -p 4726 -bp 4727 --chromedriver-port 4728 -U "ZY223XJFNS"
I have followed below appium guidelines for starting appium servers :
https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/parallel-tests.md
2) I have created two testng classes to hold both test cases. Below is the code for both the classes and tetng xml file.
3) I am printing appium session in both test cases. For which different values are printed. Even appium logs suggest that both the appium driver are interacting to their respective servers.
In both test I am using different application, but only one test cases pass and one fail. In both test cases I take screenshot which give screenshot of same devices.
Test 1
package com.qklab.register;
import java.io.File;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.testng.annotations.Test;
import com.qk.automation.framework.AppiumManagerTestng;
import io.appium.java_client.AppiumDriver;
public class DeviceOneAppOne
@Test
public void test1(HashMap<String,Object> testDetail) throws Exception
HashMap<String, String> deviceDetails = new HashMap<String, String>();
deviceDetails.put("app_activity","com.hdfc.retail.netbanking.HDFCBank");
deviceDetails.put("app_package","com.snapwork.hdfc");
deviceDetails.put("appium_port","4726");
deviceDetails.put("appium_ip","0.0.0.0");
deviceDetails.put("udid","ZY223XJFNS");
deviceDetails.put("device_name","moto black");
deviceDetails.put("platform_version","8.1.0");
deviceDetails.put("platform_name","Android");
AppiumManagerTestng appiumManager = new AppiumManagerTestng();
AppiumDriver appiumDriver = appiumManager.getAppiumDriverForTestng(deviceDetails);
try
System.out.println("got session id : " + appiumDriver.getSessionId());
//Take screenshot
File srcFile=appiumDriver.getScreenshotAs(OutputType.FILE);
File targetFile=new File("ZY223XJFNS" +".jpg");
System.out.println(targetFile.getAbsolutePath());
FileUtils.copyFile(srcFile,targetFile);
appiumDriver.findElement(By.xpath("//*[@*[contains(.,'SKIP INTRODUCTION')]]")).click();
catch(Exception ex)
throw ex;
2) Test 2
package com.qklab.register;
import java.io.File;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.testng.annotations.Test;
import com.qk.automation.framework.AppiumManagerTestng;
import io.appium.java_client.AppiumDriver;
public class DeviceTwoAppTwo
@Test
public void test2(HashMap<String,Object> testDetail) throws Exception
HashMap<String, String> deviceDetails = new HashMap<String, String>();
deviceDetails.put("app_activity","com.atomyes.MainActivity");
deviceDetails.put("app_package","com.atomyes");
deviceDetails.put("appium_port","4723");
deviceDetails.put("appium_ip","0.0.0.0");
deviceDetails.put("udid","ZY3223QGDP");
deviceDetails.put("device_name","moto silver");
deviceDetails.put("platform_version","7.0");
deviceDetails.put("platform_name","Android");
AppiumManagerTestng appiumManager = new AppiumManagerTestng();
AppiumDriver appiumDriver = appiumManager.getAppiumDriverForTestng(deviceDetails);
try
//Take screenshot
File srcFile=appiumDriver.getScreenshotAs(OutputType.FILE);
File targetFile=new File("ZY3223QGDP" +".jpg");
FileUtils.copyFile(srcFile,targetFile);
appiumDriver.findElement(By.xpath("//*[@text='Skip To Login']")).click();
catch(Exception ex)
Thread.sleep(10000);
throw ex;
3) AppiumDriver generator
package com.qk.automation.framework;
import java.net.URL;
import java.util.HashMap;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
public class AppiumManagerTestng
public AppiumDriver getAppiumDriverForTestng(HashMap<String, String> deviceDetails) throws Exception
AppiumDriver driverForTestng = null;
String app_activity = deviceDetails.get("app_activity");
String app_package = deviceDetails.get("app_package");
String appium_port = deviceDetails.get("appium_port");
String appium_ip = deviceDetails.get("appium_ip");
String udid = deviceDetails.get("udid");
String device_name = deviceDetails.get("device_name");
String platform_version = deviceDetails.get("platform_version");
String platform_name = deviceDetails.get("platform_name");
try
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, device_name);
dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, platform_version);
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, platform_name);
dc.setCapability(MobileCapabilityType.UDID, udid);
dc.setCapability(MobileCapabilityType.NO_RESET, false);
//dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, app_package);
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, app_activity);
driverForTestng = new AppiumDriver(new URL("http://" + appium_ip + ":" + appium_port + "/wd/hub"),dc);
catch(Exception objDriverException)
objDriverException.printStackTrace();
return driverForTestng;
4) Testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests" thread-count="2">
<test name="Test1">
<classes>
<class name="com.qklab.register.DeviceOneAppOne">
<methods>
<include name="test1" />
</methods>
</class>
</classes>
</test>
<test name="Test2">
<classes>
<class name="com.qklab.register.DeviceTwoAppTwo">
<methods>
<include name="test2" />
</methods>
</class>
</classes>
</test>
</suite>
Above code should run both test cases independently of each other. But this is not happening. Any help would be appreciated.
java testng appium appium-android
I am trying to run two different test cases parallelly on two different devices. I am doing following steps to run the test cases :
1) Open two appium server instances using below commands
appium -p 4723 -bp 4724 --chromedriver-port 4725 -U "ZY3223QGDP"
appium -p 4726 -bp 4727 --chromedriver-port 4728 -U "ZY223XJFNS"
I have followed below appium guidelines for starting appium servers :
https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/parallel-tests.md
2) I have created two testng classes to hold both test cases. Below is the code for both the classes and tetng xml file.
3) I am printing appium session in both test cases. For which different values are printed. Even appium logs suggest that both the appium driver are interacting to their respective servers.
In both test I am using different application, but only one test cases pass and one fail. In both test cases I take screenshot which give screenshot of same devices.
Test 1
package com.qklab.register;
import java.io.File;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.testng.annotations.Test;
import com.qk.automation.framework.AppiumManagerTestng;
import io.appium.java_client.AppiumDriver;
public class DeviceOneAppOne
@Test
public void test1(HashMap<String,Object> testDetail) throws Exception
HashMap<String, String> deviceDetails = new HashMap<String, String>();
deviceDetails.put("app_activity","com.hdfc.retail.netbanking.HDFCBank");
deviceDetails.put("app_package","com.snapwork.hdfc");
deviceDetails.put("appium_port","4726");
deviceDetails.put("appium_ip","0.0.0.0");
deviceDetails.put("udid","ZY223XJFNS");
deviceDetails.put("device_name","moto black");
deviceDetails.put("platform_version","8.1.0");
deviceDetails.put("platform_name","Android");
AppiumManagerTestng appiumManager = new AppiumManagerTestng();
AppiumDriver appiumDriver = appiumManager.getAppiumDriverForTestng(deviceDetails);
try
System.out.println("got session id : " + appiumDriver.getSessionId());
//Take screenshot
File srcFile=appiumDriver.getScreenshotAs(OutputType.FILE);
File targetFile=new File("ZY223XJFNS" +".jpg");
System.out.println(targetFile.getAbsolutePath());
FileUtils.copyFile(srcFile,targetFile);
appiumDriver.findElement(By.xpath("//*[@*[contains(.,'SKIP INTRODUCTION')]]")).click();
catch(Exception ex)
throw ex;
2) Test 2
package com.qklab.register;
import java.io.File;
import java.util.HashMap;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.testng.annotations.Test;
import com.qk.automation.framework.AppiumManagerTestng;
import io.appium.java_client.AppiumDriver;
public class DeviceTwoAppTwo
@Test
public void test2(HashMap<String,Object> testDetail) throws Exception
HashMap<String, String> deviceDetails = new HashMap<String, String>();
deviceDetails.put("app_activity","com.atomyes.MainActivity");
deviceDetails.put("app_package","com.atomyes");
deviceDetails.put("appium_port","4723");
deviceDetails.put("appium_ip","0.0.0.0");
deviceDetails.put("udid","ZY3223QGDP");
deviceDetails.put("device_name","moto silver");
deviceDetails.put("platform_version","7.0");
deviceDetails.put("platform_name","Android");
AppiumManagerTestng appiumManager = new AppiumManagerTestng();
AppiumDriver appiumDriver = appiumManager.getAppiumDriverForTestng(deviceDetails);
try
//Take screenshot
File srcFile=appiumDriver.getScreenshotAs(OutputType.FILE);
File targetFile=new File("ZY3223QGDP" +".jpg");
FileUtils.copyFile(srcFile,targetFile);
appiumDriver.findElement(By.xpath("//*[@text='Skip To Login']")).click();
catch(Exception ex)
Thread.sleep(10000);
throw ex;
3) AppiumDriver generator
package com.qk.automation.framework;
import java.net.URL;
import java.util.HashMap;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
public class AppiumManagerTestng
public AppiumDriver getAppiumDriverForTestng(HashMap<String, String> deviceDetails) throws Exception
AppiumDriver driverForTestng = null;
String app_activity = deviceDetails.get("app_activity");
String app_package = deviceDetails.get("app_package");
String appium_port = deviceDetails.get("appium_port");
String appium_ip = deviceDetails.get("appium_ip");
String udid = deviceDetails.get("udid");
String device_name = deviceDetails.get("device_name");
String platform_version = deviceDetails.get("platform_version");
String platform_name = deviceDetails.get("platform_name");
try
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, device_name);
dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, platform_version);
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, platform_name);
dc.setCapability(MobileCapabilityType.UDID, udid);
dc.setCapability(MobileCapabilityType.NO_RESET, false);
//dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, app_package);
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, app_activity);
driverForTestng = new AppiumDriver(new URL("http://" + appium_ip + ":" + appium_port + "/wd/hub"),dc);
catch(Exception objDriverException)
objDriverException.printStackTrace();
return driverForTestng;
4) Testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests" thread-count="2">
<test name="Test1">
<classes>
<class name="com.qklab.register.DeviceOneAppOne">
<methods>
<include name="test1" />
</methods>
</class>
</classes>
</test>
<test name="Test2">
<classes>
<class name="com.qklab.register.DeviceTwoAppTwo">
<methods>
<include name="test2" />
</methods>
</class>
</classes>
</test>
</suite>
Above code should run both test cases independently of each other. But this is not happening. Any help would be appreciated.
java testng appium appium-android
java testng appium appium-android
asked Mar 28 at 14:12
uttam.aaseriuttam.aaseri
152 bronze badges
152 bronze badges
Can you please add more details about what is the error that you are seeing? Your code looks threadsafe and I dont see any evident problems in it.
– Krishnan Mahadevan
Mar 29 at 8:48
Curious to know that are these class/tests running at all? Because the test method require one argumentHashMap<String,Object> testDetail
and it is not passed either as parameter or using data-provider. Regardless, While starting appium, instead of using-U
which is deprecated, you can try-dc
or--default-capabilities
. For example:--default-capabilities [ '"app": "myapp.app", "deviceName": "iPhone Simulator"' | /path/to/caps.json ]
.
– user861594
Mar 31 at 4:39
add a comment
|
Can you please add more details about what is the error that you are seeing? Your code looks threadsafe and I dont see any evident problems in it.
– Krishnan Mahadevan
Mar 29 at 8:48
Curious to know that are these class/tests running at all? Because the test method require one argumentHashMap<String,Object> testDetail
and it is not passed either as parameter or using data-provider. Regardless, While starting appium, instead of using-U
which is deprecated, you can try-dc
or--default-capabilities
. For example:--default-capabilities [ '"app": "myapp.app", "deviceName": "iPhone Simulator"' | /path/to/caps.json ]
.
– user861594
Mar 31 at 4:39
Can you please add more details about what is the error that you are seeing? Your code looks threadsafe and I dont see any evident problems in it.
– Krishnan Mahadevan
Mar 29 at 8:48
Can you please add more details about what is the error that you are seeing? Your code looks threadsafe and I dont see any evident problems in it.
– Krishnan Mahadevan
Mar 29 at 8:48
Curious to know that are these class/tests running at all? Because the test method require one argument
HashMap<String,Object> testDetail
and it is not passed either as parameter or using data-provider. Regardless, While starting appium, instead of using -U
which is deprecated, you can try -dc
or --default-capabilities
. For example: --default-capabilities [ '"app": "myapp.app", "deviceName": "iPhone Simulator"' | /path/to/caps.json ]
.– user861594
Mar 31 at 4:39
Curious to know that are these class/tests running at all? Because the test method require one argument
HashMap<String,Object> testDetail
and it is not passed either as parameter or using data-provider. Regardless, While starting appium, instead of using -U
which is deprecated, you can try -dc
or --default-capabilities
. For example: --default-capabilities [ '"app": "myapp.app", "deviceName": "iPhone Simulator"' | /path/to/caps.json ]
.– user861594
Mar 31 at 4:39
add a comment
|
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399718%2fappium-session-running-on-same-device-in-parallel-execution%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399718%2fappium-session-running-on-same-device-in-parallel-execution%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you please add more details about what is the error that you are seeing? Your code looks threadsafe and I dont see any evident problems in it.
– Krishnan Mahadevan
Mar 29 at 8:48
Curious to know that are these class/tests running at all? Because the test method require one argument
HashMap<String,Object> testDetail
and it is not passed either as parameter or using data-provider. Regardless, While starting appium, instead of using-U
which is deprecated, you can try-dc
or--default-capabilities
. For example:--default-capabilities [ '"app": "myapp.app", "deviceName": "iPhone Simulator"' | /path/to/caps.json ]
.– user861594
Mar 31 at 4:39