Commit a8f68b31f04e0165a0817b12a55db0e1ac2057f0
1 parent
79149350
开发梳理;
Showing
2 changed files
with
22 additions
and
5 deletions
Show diff stats
src/main/java/com/essa/framework/BrowserEngine.java
... | ... | @@ -19,7 +19,9 @@ public class BrowserEngine { |
19 | 19 | private ConfigProperties configProperties; |
20 | 20 | |
21 | 21 | public void initConfigData() throws IOException{ |
22 | + env1 = null == env1 ? EnvEnum.SIT : env1; | |
22 | 23 | configProperties = ConfigProperties.getConfig(env1); |
24 | + browserEnum = BrowserEnum.fromCode(configProperties.getBrowserName()); | |
23 | 25 | Model.setEnv(env1.getCode());//我也不知道为什么执行完上面的代码后,env会变为sit |
24 | 26 | } |
25 | 27 | /** |
... | ... | @@ -37,6 +39,7 @@ public class BrowserEngine { |
37 | 39 | * @return |
38 | 40 | */ |
39 | 41 | private WebDriver getBrowser(BrowserEnum browser,String url,int waitTime){ |
42 | + System.setProperty(browser.getExeName(), ".\\src\\main\\resources\\" + browser.getDriver()); | |
40 | 43 | switch(browser) { |
41 | 44 | case Firefox:{ |
42 | 45 | driver = new FirefoxDriver(); |
... | ... | @@ -50,7 +53,7 @@ public class BrowserEngine { |
50 | 53 | driver = new InternetExplorerDriver(); |
51 | 54 | } |
52 | 55 | } |
53 | - System.setProperty("webdriver.gecko.driver", ".\\src\\main\\resources\\" + browser.getDriver()); | |
56 | + | |
54 | 57 | Logger.Output(LogType.LogTypeName.INFO, "正在启动" + browser.getCode() +"浏览器"); |
55 | 58 | driver.manage().window().maximize(); |
56 | 59 | Logger.Output(LogType.LogTypeName.INFO, "窗口最大化"); | ... | ... |
src/main/java/com/essa/framework/BrowserEnum.java
... | ... | @@ -8,9 +8,9 @@ import java.util.concurrent.ConcurrentHashMap; |
8 | 8 | import java.util.concurrent.atomic.AtomicReference; |
9 | 9 | |
10 | 10 | public enum BrowserEnum { |
11 | - Firefox("Firefox","geckodriver.exe"), | |
12 | - Chrome("Chrome","chromedriver.exe"), | |
13 | - IE("IE","IEDriverServer.exe"); | |
11 | + Firefox("Firefox","webdriver.gecko.driver","geckodriver.exe"), | |
12 | + Chrome("Chrome","webdriver.chrome.driver","chromedriver.exe"), | |
13 | + IE("IE","webdriver.ie.driver","IEDriverServer.exe"); | |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * 原子引用(全部) |
... | ... | @@ -57,6 +57,11 @@ public enum BrowserEnum { |
57 | 57 | */ |
58 | 58 | private String driver; |
59 | 59 | |
60 | + /** | |
61 | + * exe 名字 | |
62 | + */ | |
63 | + private String exeName; | |
64 | + | |
60 | 65 | public String getCode() { |
61 | 66 | return code; |
62 | 67 | } |
... | ... | @@ -73,9 +78,18 @@ public enum BrowserEnum { |
73 | 78 | this.driver = driver; |
74 | 79 | } |
75 | 80 | |
76 | - BrowserEnum(String code, String driver) { | |
81 | + public String getExeName() { | |
82 | + return exeName; | |
83 | + } | |
84 | + | |
85 | + public void setExeName(String exeName) { | |
86 | + this.exeName = exeName; | |
87 | + } | |
88 | + | |
89 | + BrowserEnum(String code,String exeName, String driver) { | |
77 | 90 | this.code = code; |
78 | 91 | this.driver = driver; |
92 | + this.exeName = exeName; | |
79 | 93 | } |
80 | 94 | |
81 | 95 | public static List<BrowserEnum> getAllEnum() { | ... | ... |