- oldie
- Posts : 2
Join date : 2014-01-22
How to share one browser between 2 classes?
Thu Jan 23, 2014 3:13 am
I have 2 classes:
public class Try {
private Selenium selenium;
@Before
public void setUp() throws Exception {
WebDriver driver = new FirefoxDriver();
String baseUrl = link; //(sorry I am not allowed to put a link as a new member)
selenium = new WebDriverBackedSelenium(driver, baseUrl);
}
@Test
public void testing() throws Exception{
shared.logIn call_logIn = new shared.logIn();
Selenium selenium = call_logIn.login();
selenium.type("id=gbqfq", "Best");
}
it calls:
public class logIn {
private Selenium selenium;
public Selenium login() throws Exception{
WebDriver driver = new FirefoxDriver();
String baseUrl = link; //(sorry again I am not allowed to put a link as a new member)
selenium = new WebDriverBackedSelenium(driver, baseUrl);
selenium.open("#q=test");
return selenium;
}
1. the first class calls the second
2. the second opens link and returns to the first class
3. the first class types in the input box 'Best'
The problem is: the first class opens browser, then the second class opens another one.
How I can do everything in one browser?
public class Try {
private Selenium selenium;
@Before
public void setUp() throws Exception {
WebDriver driver = new FirefoxDriver();
String baseUrl = link; //(sorry I am not allowed to put a link as a new member)
selenium = new WebDriverBackedSelenium(driver, baseUrl);
}
@Test
public void testing() throws Exception{
shared.logIn call_logIn = new shared.logIn();
Selenium selenium = call_logIn.login();
selenium.type("id=gbqfq", "Best");
}
it calls:
public class logIn {
private Selenium selenium;
public Selenium login() throws Exception{
WebDriver driver = new FirefoxDriver();
String baseUrl = link; //(sorry again I am not allowed to put a link as a new member)
selenium = new WebDriverBackedSelenium(driver, baseUrl);
selenium.open("#q=test");
return selenium;
}
1. the first class calls the second
2. the second opens link and returns to the first class
3. the first class types in the input box 'Best'
The problem is: the first class opens browser, then the second class opens another one.
How I can do everything in one browser?
- Issues with IE close browser, Firefox window focus. unable to get screenshots any browser
- Selenium.SeleniumException : Failed to start new browser session: Error while launching browser
- Open Browser Keyword of Selenium2Library (robotframework) is giving: is not a supported browser.
- How to embed webdriver browser into java GUI/ attach to exsisting browser
- possible to use without browser?
Permissions in this forum:
You cannot reply to topics in this forum