Trying to run a JUnit script exported from the Selenium IDE

8 views
Skip to first unread message

tad604

unread,
Jul 29, 2011, 10:21:21 AM7/29/11
to Selenium Users
I've installed the selenium IDE in fire fox and made a quick test and
exported it to JUnit. I then tried repeatedly to get it to run from
inside eclipse using the JUnit test runner.... after giving up trying
to hunt down every dependency necessary to run the test I created a
maven selenium project using the example pom.xml from this site.
Added a test src folder to the new maven project dropped the Junit
test exported from the Selenium IDE into the test folder and tried
running the unit test. I received the following error:

java.lang.RuntimeException: Could not start Selenium session: You may
not start more than one session at a time
at
com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:
90)
...
Caused by: com.thoughtworks.selenium.SeleniumException: You may not
start more than one session at a time
at
org.openqa.selenium.WebDriverCommandProcessor.start(WebDriverCommandProcessor.java:
122)
at
org.openqa.selenium.WebDriverCommandProcessor.start(WebDriverCommandProcessor.java:
113)
at
com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:
82)
... 25 more

if I remove the "selenium.start()" command in the setup() method I
get a null pointer exception when I first execute a method on the
selenium object.


.....

Ok while typing this out I fixed my own issue. The Junit exported
was creating a new selenium object in the setup method and then using
the selenium object created in the super class. Calling start on the
new object was throwing the exception. Removing the start would
allow the test to get a little further and then fail when you tried to
actually use the Selenium object. Updating the setup to set the
super.selenium object instead of setting it to a new variable seemed
to fix the issue.

Changing:
public void setUp() throws Exception {
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://dev.dl.com/";
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
selenium.start();
}

to:

public void setUp() throws Exception {
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://dev.dl.com/";
selenium = new WebDriverBackedSelenium(driver, baseUrl);

}

fixed the issue.
Reply all
Reply to author
Forward
0 new messages