java-client icon indicating copy to clipboard operation
java-client copied to clipboard

Unable to run the test parallelly on 2 devices through testng (appium java) > code runs individually << failed due to unable to locate the element

Open lakshmividyadharan opened this issue 3 years ago • 2 comments

testng XML :

Test : package tests;

import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.Method; import java.util.Properties; import java.util.concurrent.TimeUnit;

import org.testng.Assert; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test;

//import Practice.BluesecureTC.Base1; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import pages.GetVerificationCodePage; import pages.InviteUserPage; import pages.OTPVerificationPage; import pages.SplashPage; import utils.Base; import utils.Base2;

public class Muti_LoginTC2 extends Base2{

@BeforeTest()
public void killAllnodes() throws IOException, InterruptedException {  
	Runtime.getRuntime().exec("taskkill /F /IM node.exe");
	Thread.sleep(3000);
}

// @AfterTest // public void stop() // { // stop_service(); // } //

@Test 
public void login1() throws IOException, InterruptedException
{
	
	
	AndroidDriver<AndroidElement> driver1 = startServer("8244","Bluesecure","RZ8R915W2KW");
	driver1.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	System.out.println("Thread one is" +Thread.currentThread().getId());
	
	SplashPage s1=new SplashPage(driver1);
	
	GetVerificationCodePage verify = new GetVerificationCodePage(driver1);
	OTPVerificationPage otp = new OTPVerificationPage(driver1);
	
	s1.naviagte();

// String expected="android.widget.ScrollView"; // String actual =

	verify.allow_permissions();
	verify.login("8755875532");
	otp.verifyOtp();
	
}

@Test
public void login2() throws IOException, InterruptedException
{
	AndroidDriver<AndroidElement> driver2 = startServer("8241","Bluesecure","HA4L6TGQGET4CMDI");
	//AndroidDriver<AndroidElement> driver = capabilities("Bluesecure");
	driver2.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	System.out.println("Thread two  is" +Thread.currentThread().getId());
	
	SplashPage s2=new SplashPage(driver2);
	
	
	GetVerificationCodePage verify2 = new GetVerificationCodePage(driver2);
	OTPVerificationPage otp2 = new OTPVerificationPage(driver2);
	
	s2.naviagte();

// String expected="android.widget.ScrollView"; // String actual =

	verify2.allow_permissions();
	verify2.login("9544696100");
	otp2.verifyOtp();

// }

// @Test // public void login3() throws IOException, InterruptedException // { // AndroidDriver<AndroidElement> driver = startServer("8997","Bluesecure","RZ8R915W2KW"); // //AndroidDriver<AndroidElement> driver = capabilities("Bluesecure"); // driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // // // SplashPage s1=new SplashPage(driver); // // GetVerificationCodePage verify = new GetVerificationCodePage(driver); // OTPVerificationPage otp = new OTPVerificationPage(driver); // // s1.naviagte(); //// String expected="android.widget.ScrollView"; //// String actual = // // verify.allow_permissions(); // verify.login("9544696100"); // otp.verifyOtp(); //// // } }

lakshmividyadharan avatar Sep 16 '22 07:09 lakshmividyadharan

one device test pass, other device test will stop without locating any element

lakshmividyadharan avatar Sep 16 '22 07:09 lakshmividyadharan

@lakshmividyadharan - I think it may be because you doing something wrong in your code or setup. There are multiple ways to perform parallel execution.

  1. You can have same appium server with different port
  2. You can have two different appium server pointing your tests to them

Plesae refer to this video - https://www.youtube.com/watch?v=Z7vIuEWmi3A&list=PL9ok7C7Yn9A9qy5rqMiFtGHPbwM9yOxCW&index=7

amuthansakthivel avatar Feb 08 '23 06:02 amuthansakthivel