我已经声明了属性文件并在一个类中初始化了 Webdriver 对象。现在我想在同一个包或另一个包中的任何地方使用这个 Webdriver 对象。如何?
请在下面找到代码:
public class Config
{
public static Properties config =null;
public static Properties OR = null;
public static WebDriver driver = null ;
public static Logger APPLICATION_LOGS = Logger.getLogger("devpinoyLogger");
@SuppressWarnings("unused")
public void initialization() throws IOException
{
// creating properties files storing the ID's and xpaths
APPLICATION_LOGS.debug("Starting the test suite");
APPLICATION_LOGS.debug("Loading config files");
config = new Properties();
//FileInputStream fp = new FileInputStream("./config.properties");
FileInputStream fp = new FileInputStream(System.getProperty("user.dir")+"\\src\\com\\ode\\utility\\config.properties");
config.load(fp);
APPLICATION_LOGS.debug("Loading Object XPATHS");
OR = new Properties();
//FileInputStream fp1 = new FileInputStream("./OR.properties");
FileInputStream fp1 = new FileInputStream(System.getProperty("user.dir")+"\\src\\com\\ode\\utility\\OR.properties");
OR.load(fp1);
APPLICATION_LOGS.debug("Starting the driver");
driver = new InternetExplorerDriver();
driver.get(config.getProperty("Testwebsite"));
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
}
我不知道如何使用这个...帮我解决这个问题...
帮助将不胜感激..