1
votes

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.

1
Are you sure the voyagein_id is "global"? That means, is it a public (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 the String type declaration in your code snippet? - Petr Janeček
Yes it is global "public static String voyagein_id;" in the first script, it fetches the value of the voyagein_id and prints but for the 2nd it shows null - Riy1234
@ Slance , @Umamaheshwar - Thanks I got it, I have declared the Variable twice once in global and the other inside the method.Was dumb to uderstand first +1 - Riy1234

1 Answers

0
votes

Please verify your OR.properties file once and copy it at correct location where the code is looking. I think you have not updated the properties file correctly. I too faced the same problem day before yesterday only. I have updated the properties file where the jar file is copied, then it worked. Before that i too got Null value.

Are you running any Jar file or directly from Eclipse?