n00b: prob building project for selenium in eclipse [message #831251] |
Wed, 28 March 2012 17:09 |
Eclipse User |
|
|
|
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 #831366 is a reply to message #831333] |
Wed, 28 March 2012 20:27 |
Eclipse User |
|
|
|
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 #831485 is a reply to message #831471] |
Thu, 29 March 2012 00:34 |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.01887 seconds