How to call a method from one class to another class when both are TestNG classes up vote

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

How to call a method from one class to another class when both are TestNG classes up vote

sachin patil
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

cassian
What do you mean by calling method?? Are you trying to call one @Test method from another @Test method??

On Sun, Jun 10, 2018, 6:42 PM sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

sachin patil
I have two classes as mentioned below.


public class ClassA {
public void method1()
    {
        System.out.println("Selenium_1");
    }
   public void method2()
    {
        System.out.println("Selenium_2");
    }
    
}
=============================
public class ClassB {

public static void main(String[] args) {
       
 
 System.out.println("executing class A");
 ClassA rt1=new ClassA();
rt1.method1();
rt1.method1();
   
}
 
}

After running the ClassB it's executed properly but when i execute my orginal script which has more code(from real project) i am getting NullPointer exception.

Why this is happening?

Please help me on this.


Best Regard
Sachin Patil
+91-9552619077


On Sun, Jun 10, 2018 at 10:35 PM, Cassian Raja Thomas <[hidden email]> wrote:
What do you mean by calling method?? Are you trying to call one @Test method from another @Test method??

On Sun, Jun 10, 2018, 6:42 PM sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

cassian
These classes looks good to be executed. But unless you show the actual code, I will not be able to provide any help. Also, try to debug the code using your IDE to find out the line where there is a null reference.

Thanks & Regards,
Cassian Raja .T

On Mon, Jun 11, 2018 at 10:27 AM, sachin patil <[hidden email]> wrote:
I have two classes as mentioned below.


public class ClassA {
public void method1()
    {
        System.out.println("Selenium_1");
    }
   public void method2()
    {
        System.out.println("Selenium_2");
    }
    
}
=============================
public class ClassB {

public static void main(String[] args) {
       
 
 System.out.println("executing class A");
 ClassA rt1=new ClassA();
rt1.method1();
rt1.method1();
   
}
 
}

After running the ClassB it's executed properly but when i execute my orginal script which has more code(from real project) i am getting NullPointer exception.

Why this is happening?

Please help me on this.


Best Regard
Sachin Patil
+91-9552619077


On Sun, Jun 10, 2018 at 10:35 PM, Cassian Raja Thomas <[hidden email]> wrote:
What do you mean by calling method?? Are you trying to call one @Test method from another @Test method??

On Sun, Jun 10, 2018, 6:42 PM sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKvtLQHJs02e7LyTo5r56yc-4QNSSdGtRZhHyY1e9v_E%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

Sowjanya Karumuri
In reply to this post by sachin patil

You need to have driver in ur constructor in both classes. Then it will work. 

On Mon, Jun 11, 2018 at 1:52 AM sachin patil <[hidden email]> wrote:
I have two classes as mentioned below.


public class ClassA {
public void method1()
    {
        System.out.println("Selenium_1");
    }
   public void method2()
    {
        System.out.println("Selenium_2");
    }
    
}
=============================
public class ClassB {

public static void main(String[] args) {
       
 
 System.out.println("executing class A");
 ClassA rt1=new ClassA();
rt1.method1();
rt1.method1();
   
}
 
}

After running the ClassB it's executed properly but when i execute my orginal script which has more code(from real project) i am getting NullPointer exception.

Why this is happening?

Please help me on this.


Best Regard
Sachin Patil
+91-9552619077


On Sun, Jun 10, 2018 at 10:35 PM, Cassian Raja Thomas <[hidden email]> wrote:
What do you mean by calling method?? Are you trying to call one @Test method from another @Test method??

On Sun, Jun 10, 2018, 6:42 PM sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Sowjanya
---------------------
Be the change you wish to see in the world

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAM%2BNpKBCJGQMCiH5ir4BvsCfxUdMgbHnR8BNeeD6HbztBvm2Xw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

sachin patil
Hello,

I am sharing real code with you as i am getting error called "Exception in thread "main" java.lang.NullPointerException" while method from one class to another class.
Please look into ClassA and ClassB.
Help me with this.

public class ClassA {
public static AndroidDriver driver;
public void launch() throws MalformedURLException
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Honor");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "7.0");
     caps.setCapability("udid", "192.168.157.101:5555");
caps.setCapability("appPackage", "com.torenzo.torenzocafe");
caps.setCapability("appActivity", "com.torenzo.torenzopos.StartScreenActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps);
}
public void login()
{
driver.findElement(By.id("com.torenzo.torenzocafe:id/submit_login")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/clock_in")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/role_name")).click();
  System.out.println("on home page");
}


}

==================
public class ClassB {
public static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException {
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
ClassA call = new ClassA();
call.launch();
call.login();
ClassB call1 = new ClassB();
call1.TakeoutOrder();
}

public void TakeoutOrder(){

System.out.println("Order creation process is started");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.id("com.torenzo.torenzocafe:id/new_order_create_btn_layout")).click();
String order_no=driver.findElement(By.id("com.torenzo.torenzocafe:id/order_no")).getText();
System.out.println("Order number is =>" + order_no);
driver.findElement(By.xpath("//android.widget.TextView[@text='All Items']")).click();
for (int i=3; i<5; i++)
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_btn")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_two")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_done")).click();
for (int g=1; g<3; g++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'card_view') and @index="+g+"]")).click();
for (int i=1; i<3; i++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
}
}
}







Best Regard
Sachin Patil
+91-9552619077


On Mon, Jun 11, 2018 at 4:44 PM, Sowjanya Karumuri <[hidden email]> wrote:

You need to have driver in ur constructor in both classes. Then it will work. 

On Mon, Jun 11, 2018 at 1:52 AM sachin patil <[hidden email]> wrote:
I have two classes as mentioned below.


public class ClassA {
public void method1()
    {
        System.out.println("Selenium_1");
    }
   public void method2()
    {
        System.out.println("Selenium_2");
    }
    
}
=============================
public class ClassB {

public static void main(String[] args) {
       
 
 System.out.println("executing class A");
 ClassA rt1=new ClassA();
rt1.method1();
rt1.method1();
   
}
 
}

After running the ClassB it's executed properly but when i execute my orginal script which has more code(from real project) i am getting NullPointer exception.

Why this is happening?

Please help me on this.


Best Regard
Sachin Patil
+91-9552619077


On Sun, Jun 10, 2018 at 10:35 PM, Cassian Raja Thomas <[hidden email]> wrote:
What do you mean by calling method?? Are you trying to call one @Test method from another @Test method??

On Sun, Jun 10, 2018, 6:42 PM sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Sowjanya
---------------------
Be the change you wish to see in the world

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAM%2BNpKBCJGQMCiH5ir4BvsCfxUdMgbHnR8BNeeD6HbztBvm2Xw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rEhjY2WABQe-dav%2BaKXF9D5S%2BBnpSROEy_GR23kA0DqcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

sachin patil
Can you please send modify the code like how it's work for calling a method from one class to another class for TestNG framework and simple java class file as well as i made above class file(automation). 

Best Regard
Sachin Patil
+91-9552619077


On Fri, Jun 15, 2018 at 4:49 PM, sachin patil <[hidden email]> wrote:
Hello,

I am sharing real code with you as i am getting error called "Exception in thread "main" java.lang.NullPointerException" while method from one class to another class.
Please look into ClassA and ClassB.
Help me with this.

public class ClassA {
public static AndroidDriver driver;
public void launch() throws MalformedURLException
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Honor");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "7.0");
     caps.setCapability("udid", "192.168.157.101:5555");
caps.setCapability("appPackage", "com.torenzo.torenzocafe");
caps.setCapability("appActivity", "com.torenzo.torenzopos.StartScreenActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps);
}
public void login()
{
driver.findElement(By.id("com.torenzo.torenzocafe:id/submit_login")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/clock_in")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/role_name")).click();
  System.out.println("on home page");
}


}

==================
public class ClassB {
public static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException {
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
ClassA call = new ClassA();
call.launch();
call.login();
ClassB call1 = new ClassB();
call1.TakeoutOrder();
}

public void TakeoutOrder(){

System.out.println("Order creation process is started");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.id("com.torenzo.torenzocafe:id/new_order_create_btn_layout")).click();
String order_no=driver.findElement(By.id("com.torenzo.torenzocafe:id/order_no")).getText();
System.out.println("Order number is =>" + order_no);
driver.findElement(By.xpath("//android.widget.TextView[@text='All Items']")).click();
for (int i=3; i<5; i++)
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_btn")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_two")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_done")).click();
for (int g=1; g<3; g++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'card_view') and @index="+g+"]")).click();
for (int i=1; i<3; i++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
}
}
}







Best Regard
Sachin Patil
+91-9552619077


On Mon, Jun 11, 2018 at 4:44 PM, Sowjanya Karumuri <[hidden email]> wrote:

You need to have driver in ur constructor in both classes. Then it will work. 

On Mon, Jun 11, 2018 at 1:52 AM sachin patil <[hidden email]> wrote:
I have two classes as mentioned below.


public class ClassA {
public void method1()
    {
        System.out.println("Selenium_1");
    }
   public void method2()
    {
        System.out.println("Selenium_2");
    }
    
}
=============================
public class ClassB {

public static void main(String[] args) {
       
 
 System.out.println("executing class A");
 ClassA rt1=new ClassA();
rt1.method1();
rt1.method1();
   
}
 
}

After running the ClassB it's executed properly but when i execute my orginal script which has more code(from real project) i am getting NullPointer exception.

Why this is happening?

Please help me on this.


Best Regard
Sachin Patil
+91-9552619077


On Sun, Jun 10, 2018 at 10:35 PM, Cassian Raja Thomas <[hidden email]> wrote:
What do you mean by calling method?? Are you trying to call one @Test method from another @Test method??

On Sun, Jun 10, 2018, 6:42 PM sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Sowjanya
---------------------
Be the change you wish to see in the world

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAM%2BNpKBCJGQMCiH5ir4BvsCfxUdMgbHnR8BNeeD6HbztBvm2Xw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rG1T7ar%3D3PJhRQrZ1P8SJ7_%3DVS-Zxcw52BJqHDg20%2B2NA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

bharathi sriram
In reply to this post by sachin patil
By importing classes and instantiating.




On Sun, Jun 10, 2018 at 6:09 AM, sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks and Best Regards,
Bharathi

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAEwmRzhz%3D_QcYeBy%3DJKPwQ3Cvcu2yxs3NmkoyurbsO%3DEUERmRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

sachin patil
In reply to this post by sachin patil
Can you please give example?

On Fri, 15 Jun 2018, 11:56 pm bharathi sriram, <[hidden email]> wrote:
By importing classes and instantiating.




On Sun, Jun 10, 2018 at 6:09 AM, sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks and Best Regards,
Bharathi

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAEwmRzhz%3D_QcYeBy%3DJKPwQ3Cvcu2yxs3NmkoyurbsO%3DEUERmRg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rGsRNtAW9qHEfu%2BDY0XiDXMeMk%2BfESFEU%3D78_kRfVOuMA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

Scott Babcock
In reply to this post by sachin patil
In class B, I don't see any code that initializes the [driver] field. You just launch straight into trying to use whatever might be stored there. Since this field is uninitialized, you get NullPointerException.

On Friday, June 15, 2018 at 4:20:27 AM UTC-7, sachin patil wrote:
Hello,

I am sharing real code with you as i am getting error called "Exception in thread "main" java.lang.NullPointerException" while method from one class to another class.
Please look into ClassA and ClassB.
Help me with this.

public class ClassA {
public static AndroidDriver driver;
public void launch() throws MalformedURLException
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Honor");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "7.0");
     caps.setCapability("udid", "<a href="http://192.168.157.101:5555" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F192.168.157.101%3A5555\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEFmYlJsPECWvo4pL9xwGfRvgBcOw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F192.168.157.101%3A5555\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEFmYlJsPECWvo4pL9xwGfRvgBcOw&#39;;return true;">192.168.157.101:5555");
caps.setCapability("appPackage", "com.torenzo.torenzocafe");
caps.setCapability("appActivity", "com.torenzo.torenzopos.StartScreenActivity");
driver = new AndroidDriver(new URL("<a href="http://127.0.0.1:4723/wd/hub" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A4723%2Fwd%2Fhub\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEHuz5oRiFEgXk1_wGnTFu18kK6RA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A4723%2Fwd%2Fhub\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEHuz5oRiFEgXk1_wGnTFu18kK6RA&#39;;return true;">http://127.0.0.1:4723/wd/hub"), caps);
}
public void login()
{
driver.findElement(By.id("com.torenzo.torenzocafe:id/submit_login")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/clock_in")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/role_name")).click();
  System.out.println("on home page");
}


}

==================
public class ClassB {
public static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException {
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
ClassA call = new ClassA();
call.launch();
call.login();
ClassB call1 = new ClassB();
call1.TakeoutOrder();
}

public void TakeoutOrder(){

System.out.println("Order creation process is started");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.id("com.torenzo.torenzocafe:id/new_order_create_btn_layout")).click();
String order_no=driver.findElement(By.id("com.torenzo.torenzocafe:id/order_no")).getText();
System.out.println("Order number is =>" + order_no);
driver.findElement(By.xpath("//android.widget.TextView[@text='All Items']")).click();
for (int i=3; i<5; i++)
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_btn")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_two")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_done")).click();
for (int g=1; g<3; g++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'card_view') and @index="+g+"]")).click();
for (int i=1; i<3; i++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
}
}
}







Best Regard
Sachin Patil
+91-9552619077


On Mon, Jun 11, 2018 at 4:44 PM, Sowjanya Karumuri <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">shows...@...> wrote:

You need to have driver in ur constructor in both classes. Then it will work. 

On Mon, Jun 11, 2018 at 1:52 AM sachin patil <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">sachin....@...> wrote:
I have two classes as mentioned below.


public class ClassA {
public void method1()
    {
        System.out.println("Selenium_1");
    }
   public void method2()
    {
        System.out.println("Selenium_2");
    }
    
}
=============================
public class ClassB {

public static void main(String[] args) {
       
 
 System.out.println("executing class A");
 ClassA rt1=new ClassA();
rt1.method1();
rt1.method1();
   
}
 
}

After running the ClassB it's executed properly but when i execute my orginal script which has more code(from real project) i am getting NullPointer exception.

Why this is happening?

Please help me on this.


Best Regard
Sachin Patil
+91-9552619077


On Sun, Jun 10, 2018 at 10:35 PM, Cassian Raja Thomas <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rajac...@...> wrote:
What do you mean by calling method?? Are you trying to call one @Test method from another @Test method??

On Sun, Jun 10, 2018, 6:42 PM sachin patil <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">sachin....@...> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com.

For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.
--
Sowjanya
---------------------
Be the change you wish to see in the world

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zQYlewMgBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/CAM%2BNpKBCJGQMCiH5ir4BvsCfxUdMgbHnR8BNeeD6HbztBvm2Xw%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/CAM%2BNpKBCJGQMCiH5ir4BvsCfxUdMgbHnR8BNeeD6HbztBvm2Xw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/CAM%2BNpKBCJGQMCiH5ir4BvsCfxUdMgbHnR8BNeeD6HbztBvm2Xw%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/CAM%2BNpKBCJGQMCiH5ir4BvsCfxUdMgbHnR8BNeeD6HbztBvm2Xw%40mail.gmail.com.

For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/61f75afb-6d8c-472d-95b4-6d5ce1f89c4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call a method from one class to another class when both are TestNG classes up vote

sachin patil
Here you can see...

public class ClassA {
public static AndroidDriver driver;
public void launch() throws MalformedURLException
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Honor");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "7.0");
     caps.setCapability("udid", "192.168.157.101:5555");
caps.setCapability("appPackage", "com.torenzo.torenzocafe");
caps.setCapability("appActivity", "com.torenzo.torenzopos.StartScreenActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps);
}
public void login()
{
driver.findElement(By.id("com.torenzo.torenzocafe:id/submit_login")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/clock_in")).click();
 driver.findElement(By.id("com.torenzo.torenzocafe:id/role_name")).click();
  System.out.println("on home page");
}


}

==================
public class ClassB {
public static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException {
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
ClassA call = new ClassA();
call.launch();
call.login();
ClassB call1 = new ClassB();
call1.TakeoutOrder();
}

public void TakeoutOrder(){

System.out.println("Order creation process is started");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.id("com.torenzo.torenzocafe:id/new_order_create_btn_layout")).click();
String order_no=driver.findElement(By.id("com.torenzo.torenzocafe:id/order_no")).getText();
System.out.println("Order number is =>" + order_no);
driver.findElement(By.xpath("//android.widget.TextView[@text='All Items']")).click();
for (int i=3; i<5; i++)
 
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_btn")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_two")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_done")).click();
for (int g=1; g<3; g++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'card_view') and @index="+g+"]")).click();
for (int i=1; i<3; i++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
}
}
}


Best Regard
Sachin Patil
+91-9552619077


On Mon, Jun 18, 2018 at 6:14 AM, Scott Babcock <[hidden email]> wrote:
In class B, I don't see any code that initializes the [driver] field. You just launch straight into trying to use whatever might be stored there. Since this field is uninitialized, you get NullPointerException.


On Friday, June 15, 2018 at 4:20:27 AM UTC-7, sachin patil wrote:
Hello,

I am sharing real code with you as i am getting error called "Exception in thread "main" java.lang.NullPointerException" while method from one class to another class.
Please look into ClassA and ClassB.
Help me with this.

public class ClassA {
public static AndroidDriver driver;
public void launch() throws MalformedURLException
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Honor");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "7.0");
     caps.setCapability("udid", "192.168.157.101:5555");
caps.setCapability("appPackage", "com.torenzo.torenzocafe");
caps.setCapability("appActivity", "com.torenzo.torenzopos.StartScreenActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps);
}
public void login()
{
driver.findElement(By.id("com.torenzo.torenzocafe:id/submit_login")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/clock_in")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/role_name")).click();
  System.out.println("on home page");
}


}

==================
public class ClassB {
public static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException {
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
ClassA call = new ClassA();
call.launch();
call.login();
ClassB call1 = new ClassB();
call1.TakeoutOrder();
}

public void TakeoutOrder(){

System.out.println("Order creation process is started");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.id("com.torenzo.torenzocafe:id/new_order_create_btn_layout")).click();
String order_no=driver.findElement(By.id("com.torenzo.torenzocafe:id/order_no")).getText();
System.out.println("Order number is =>" + order_no);
driver.findElement(By.xpath("//android.widget.TextView[@text='All Items']")).click();
for (int i=3; i<5; i++)
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_btn")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_two")).click();
driver.findElement(By.id("com.torenzo.torenzocafe:id/add_guest_done")).click();
for (int g=1; g<3; g++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'card_view') and @index="+g+"]")).click();
for (int i=1; i<3; i++)
{
driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,'grid_menu_layout') and @index="+i+"]")).click();
}
}
}
}







Best Regard
Sachin Patil
+91-9552619077


On Mon, Jun 11, 2018 at 4:44 PM, Sowjanya Karumuri <[hidden email]> wrote:

You need to have driver in ur constructor in both classes. Then it will work. 

On Mon, Jun 11, 2018 at 1:52 AM sachin patil <[hidden email]> wrote:
I have two classes as mentioned below.


public class ClassA {
public void method1()
    {
        System.out.println("Selenium_1");
    }
   public void method2()
    {
        System.out.println("Selenium_2");
    }
    
}
=============================
public class ClassB {

public static void main(String[] args) {
       
 
 System.out.println("executing class A");
 ClassA rt1=new ClassA();
rt1.method1();
rt1.method1();
   
}
 
}

After running the ClassB it's executed properly but when i execute my orginal script which has more code(from real project) i am getting NullPointer exception.

Why this is happening?

Please help me on this.


Best Regard
Sachin Patil
+91-9552619077


On Sun, Jun 10, 2018 at 10:35 PM, Cassian Raja Thomas <[hidden email]> wrote:
What do you mean by calling method?? Are you trying to call one @Test method from another @Test method??

On Sun, Jun 10, 2018, 6:42 PM sachin patil <[hidden email]> wrote:
Guys, I am facing above problem which i mentioned in the subject line.
Can you guys please me on this?

Thanks
Sachin

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7f19523f-724f-4040-954c-dfcf3b4a3554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKsYnxsJGLtc8bv7vLxaZh_Es-%3DoLEB-Q8KBLB4VPJJPsA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rGFjCmEZEgKXSXOoOsvridMvc%2BOmA74tzMYgKRsgPxmsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Sowjanya
---------------------
Be the change you wish to see in the world

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAM%2BNpKBCJGQMCiH5ir4BvsCfxUdMgbHnR8BNeeD6HbztBvm2Xw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/61f75afb-6d8c-472d-95b4-6d5ce1f89c4f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rFYtF5sskE-nCKcZvyk4e2aw9z6Vhd4e7GpjYVeQ786Lw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.