-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.java
More file actions
74 lines (60 loc) · 1.79 KB
/
browser.java
File metadata and controls
74 lines (60 loc) · 1.79 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
65
66
67
68
69
70
71
72
73
74
package com.seek.util;
import java.io.FileInputStream;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class browser {
public WebDriver driver;
public void openbrowser(){
String brsname="firefox";
openbrowser(brsname);
}
public void openbrowser(String browsername){
if(browsername.equalsIgnoreCase("firefox"))
{
driver = new FirefoxDriver();
}
else if((browsername.toLowerCase()).matches("ie(.*)"))
{
// Update the driver path with your location
System.setProperty("webdriver.ie.driver", System.getProperty("user.dir")+"//src//data//IEDriverServer.exe");
driver = new InternetExplorerDriver();
}
else if(browsername.equalsIgnoreCase("chrome"))
{
// Update the driver path with your location
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"//src//data//chromedriver.exe");
driver = new ChromeDriver();
}else{
driver = new HtmlUnitDriver(true);
}
driver.manage().window().maximize();
}
public void openurl(String url){
driver.get(url);
}
/*
public void openurl(){
Properties config= new Properties();
try{
FileInputStream fs = new FileInputStream(OR.config_path);
config.load(fs);
} catch (Exception e){
System.out.println("File not found");
}
openurl(config.getProperty("baseurl"));
}
*/
public void closebrowser(){
driver.close();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
// browser br = new browser();
// br.openbrowser();
// br.openurl("linkedin.com");
}
}