I have a class where i get the value of the textfield, the code is below
driver.findElement(By.xpath(OR.getProperty("voyage_in"))).sendKeys("1001");
String voyagein_id=driver.findElement(By.xpath(OR.getProperty("voyage_in"))).getAttribute("value"); System.out.println(voyagein_id);
I have declared String voyagein_id as global
I have another class where i call this and the code is :
import Int_Script.Int_appointment --(This is the 2nd class)
System.out.println(Int_barge_appointment.voyagein_id);
I run both the 2 class as a suite file and always the voyagein_id is showing null.
I need to get the value of the 1st class in voyage_id and when the 2nd class runs the value of the voyagein_id must be input of the textfield.
voyagein_idis "global"? That means, is it apublic(or at least package private) instance variable of the class, and not declared locally in a method? Are you sure it's not shadowed by a local variable named the same? From your code, it looks like you're redeclaring the variable which basically ignores the original one. Does it compile if you remove theStringtype declaration in your code snippet? - Petr Janeček