Quick Search:

View

Revision:

Diff

Diff from 1175 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/jdave/branches/1.1.0/jdave-wicket-webdriver/src/java/jdave/webdriver/Browser.java

Annotated File View

karemo
1174
1 /*
2  * Copyright 2008 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package jdave.webdriver;
17
18 import java.io.IOException;
19
20 import org.openqa.selenium.WebDriver;
21 import org.openqa.selenium.firefox.FirefoxBinary;
22 import org.openqa.selenium.firefox.FirefoxLauncher;
23 import org.openqa.selenium.firefox.internal.ProfilesIni;
24
25 /**
26  * @author Juha Karemo
27  */
28 public class Browser {
29     private static final String FIREFOX_PROFILE_NAME = "WebDriver";
karemo
1175
30     
31     public void open() {
karemo
1174
32         initFirefoxProfile();
33     }
34
35     public void close() {
36         WebDriver webDriver = WebDriverHolder.get();
37         webDriver.manage().deleteAllCookies();
38         webDriver.quit();
39     }
40
41     private void initFirefoxProfile() {
42         FirefoxBinary binary = new FirefoxBinary();
43         FirefoxLauncher launcher = new FirefoxLauncher(binary);
44         ProfilesIni profiles = new ProfilesIni();
45         if (profiles.getProfile(FIREFOX_PROFILE_NAME) == null) {
46             try {
47                 launcher.createBaseWebDriverProfile(FIREFOX_PROFILE_NAME);
48             } catch (IOException e) {
49                 throw new RuntimeException(e);
50             }
51         }
52     }
53 }