forked from naveenanimation20/SeleniumJavaCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadPropFile.java
More file actions
64 lines (41 loc) · 1.83 KB
/
ReadPropFile.java
File metadata and controls
64 lines (41 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package SeleniumSessions;
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.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class ReadPropFile {
public static WebDriver driver;
public static void main(String[] args) throws IOException {
Properties prop = new Properties();
FileInputStream ip = new FileInputStream(
"/Users/naveenkhunteta/Documents/workspace/MorningSessions/src/SeleniumSessions/config.properties");
prop.load(ip);
System.out.println(prop.getProperty("name"));
System.out.println(prop.getProperty("age"));
String url = prop.getProperty("URL");
System.out.println(url);
String browserName = prop.getProperty("browser");
System.out.println(browserName);
if (browserName.equals("chrome")) {
System.setProperty("webdriver.chrome.driver", "/Users/naveenkhunteta/Downloads/chromedriver");
driver = new ChromeDriver(); // launch chrome
}
else if(browserName.equals("FF")){
System.setProperty("webdriver.chrome.driver", "/Users/naveenkhunteta/Downloads/geckodriver");
driver = new FirefoxDriver();
}
else if(browserName.equals("IE")){
System.setProperty("webdriver.chrome.driver", "/Users/naveenkhunteta/Downloads/internetexplorerdriver");
driver = new InternetExplorerDriver();
}
driver.get(url);
driver.findElement(By.xpath(prop.getProperty("firstname_xpath"))).sendKeys(prop.getProperty("firstName"));
driver.findElement(By.xpath(prop.getProperty("lastname_xpath"))).sendKeys(prop.getProperty("lastName"));
driver.findElement(By.xpath(prop.getProperty("city_xpath"))).sendKeys(prop.getProperty("city"));
}
}