任何人都可以帮我从类create_family child_tab调用或检索字符串“fam_acc_data”到另一个类parent_search_process类吗?提前谢谢了。
@Test(dependsOnMethods = "parent_form_inputs")
public create_family child_tab(String parent_form2_error_image_path) throws IOException
{
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
if(driver.findElement(child_link).isDisplayed())
{
System.out.println("Parent Information Added Successfully");
System.out.println("");
String fam_acc_data = driver.findElement(fam_acc_key).getText();
}
else
{
System.out.println("Some Error Occured Will Parent Creation");
System.out.println("");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(parent_form2_error_image_path));
System.out.println("Refer the Screen Shot Saved in: " + parent_form2_error_image_path);
System.out.println("");
}
return this;
}
答案 0 :(得分:0)
对于您的CreateFamily类中的示例,您有一个String名称:
class CreateFamily{
private String name;
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
}
现在你需要在另一个类中获取这个名字字符串,如ParentSearchProcess: -
CreateFamily createFamily=new CreateFamily();
String value="Some_name";
createFamily.setName(value); //for setting
createFamily.getName(); // for retrieving
下面是使用静态: -
class class CreateFamily{
public static String name;
}
现在您可以检索并设置以上值: -
CreateFamily.name="someValue"; //for setting
String value=CreateFamily.name; //for getting