Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » n00b: prob building project for selenium in eclipse
n00b: prob building project for selenium in eclipse [message #831251] Wed, 28 March 2012 13:09 Go to next message
Glenn Bagrowski is currently offline Glenn Bagrowski
Messages: 6
Registered: March 2012
Junior Member
I tried to follow all the directions for installing junit and associated necessities for running a webdriver for selenium. The last portion is creating a java project using the selenium IDE generated java code to run the tests. It's here that I'm having the issues.

Below I'll put the code that I'm using, but pretty much the problems have been properly setting up the run stuff (I must be doing something wrong). I ended up putting "org.junit.runner.JUnitCore" as the Main Class in the Run Configurations because I was just at a loss as what else to do.

Now I get output in the console (instead of the javaw usage stuff I was getting before) but it's really not doing anything:

JUnit version 4.8.2

Time: 0

OK (0 tests)

----------
I would prefer that it run the tests that I have in the class! I'm not even getting the test println that I stuck in there. Perhaps I'm doing something wrong in the setup??

Thank you for any help
Glenn

Code below:
----------

package com.example.tests;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class selen_test {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();

public static void main(String[] args) {
driver = new FirefoxDriver();
baseUrl = "/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

System.out.println("Page title is: ");

Deleteme test = new Deleteme();

test.testDeleteme();
}

public void testDeleteme() throws Exception {
driver.get(baseUrl + "/tymklok/personal/view/2012-03-23");
driver.findElement(By.linkText("2012-03-30")).click();
driver.findElement(By.linkText("2012-03-23")).click();
driver.findElement(By.linkText("2012-03-16")).click();
}

public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}

private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}

}
--------------
Re: n00b: prob building project for selenium in eclipse [message #831333 is a reply to message #831251] Wed, 28 March 2012 15:27 Go to previous messageGo to next message
David Wegener is currently offline David Wegener
Messages: 1336
Registered: July 2009
Senior Member
I'm not really sure what Selenium IDE or webdriver are, but if you are trying to run the class you have provided, the Main class you need to run is com.example.test.selen_test not JUnitCore.
Re: n00b: prob building project for selenium in eclipse [message #831366 is a reply to message #831333] Wed, 28 March 2012 16:27 Go to previous messageGo to next message
Glenn Bagrowski is currently offline Glenn Bagrowski
Messages: 6
Registered: March 2012
Junior Member
Hey David,

Thank you for your reply. That makes more sense.

I updated the "Main class" to "com.example.tests.selen_test", however, I'm still having a problem; it's now telling me that the class is not found:

java.lang.NoClassDefFoundError: com/example/tests/selen_test
Caused by: java.lang.ClassNotFoundException: com.example.tests.selen_test
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Re: n00b: prob building project for selenium in eclipse [message #831471 is a reply to message #831366] Wed, 28 March 2012 20:04 Go to previous messageGo to next message
David Wegener is currently offline David Wegener
Messages: 1336
Registered: July 2009
Senior Member
On 03/28/2012 03:27 PM, Glenn Bagrowski wrote:
> Hey David,
> Thank you for your reply. That makes more sense.
> I updated the "Main class" to "com.example.tests.selen_test", however,
> I'm still having a problem; it's now telling me that the class is not
> found:
>
> java.lang.NoClassDefFoundError: com/example/tests/selen_test
> Caused by: java.lang.ClassNotFoundException: com.example.tests.selen_test
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> Exception in thread "main"
>
Are you sure that you built the project to compile the class?
Re: n00b: prob building project for selenium in eclipse [message #831485 is a reply to message #831471] Wed, 28 March 2012 20:34 Go to previous message
Glenn Bagrowski is currently offline Glenn Bagrowski
Messages: 6
Registered: March 2012
Junior Member
Mayhap that's the problem. I followed the directions for setting things up for the selenium stuff, which included creating a project via command line. I then started the project using the same directory.

So I take it that perhaps I need to start over? Create the project first, then do the other stuff in the same directories, perhaps?

Thanks again for your help.
Previous Topic:How to improve the performance of code generation using JDT
Next Topic:CVS Commit error
Goto Forum:
  


Current Time: Wed Jul 30 17:26:34 EDT 2014

Powered by FUDForum. Page generated in 0.04249 seconds