package com.FrameworkStuff;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ReadProperties {
public void test() throws FileNotFoundException, IOException {
WebDriver driver=new FirefoxDriver();
driver.get("http://www.gmail.com");
driver.findElement(By.id(getProperty("Username"))).sendKeys("selenium");
driver.findElement(By.id(getProperty("Password"))).sendKeys("selenium");
}
public String getProperty(String sprop) throws FileNotFoundException, IOException {
Properties prop=new Properties();
prop.load(new FileInputStream("D:\\WebDriverExamples\\WebDriverPrograms\\src\\gmail.properties"));
String property=prop.getProperty(sprop);
return property;
}
public static void main(String[] args) throws FileNotFoundException, IOException {
ReadProperties properties=new ReadProperties();
properties.test();
}
/* Create a gmail.properties file
Username=Email
Password=Passwd
}
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ReadProperties {
public void test() throws FileNotFoundException, IOException {
WebDriver driver=new FirefoxDriver();
driver.get("http://www.gmail.com");
driver.findElement(By.id(getProperty("Username"))).sendKeys("selenium");
driver.findElement(By.id(getProperty("Password"))).sendKeys("selenium");
}
public String getProperty(String sprop) throws FileNotFoundException, IOException {
Properties prop=new Properties();
prop.load(new FileInputStream("D:\\WebDriverExamples\\WebDriverPrograms\\src\\gmail.properties"));
String property=prop.getProperty(sprop);
return property;
}
public static void main(String[] args) throws FileNotFoundException, IOException {
ReadProperties properties=new ReadProperties();
properties.test();
}
/* Create a gmail.properties file
Username=Email
Password=Passwd
}
No comments:
Post a Comment