Tag Info

Hot answers tagged

6

Selenium is a tool that remote-controls a browser. You can use it to simulate a user interacting with a web site. JUnit is a framework for writing Java unit tests. It takes some of the grunt work out of organizing tests and generating reports. You can express each test as a method on a class; typically, you have multiple tests per class. JUnit will run ...


4

Two parts to this answer: First, to answer the question, there are many test runners. Some of them by default will run in a particular order, it may be the order they appear in code, or alphabetically, or some other order. There is often a way to tell the test runner to execute them in a particular order by providing some additional command line ...


3

Use JUnit to handle the running of the tests from the Jenkins server. Use JDBC to query the DB for new rows. Change up the Tomcat servers so they send logging events back to the Jenkins serverJUnit test. You'll need to write a little socket listener for the JUnit test to gather the Tomcat events (Writing an LoggingEvent listener isn't hard. I'm not ...


3

In the Selenium Simplified course the secret to the selector is really the 'value' not the 'type' as the 'value' identifies the WebElement uniquely on that page, coupled with a type 'just in case' WebElement checkBox1; WebElement checkBox3; checkBox1 = driver.findElement(By.cssSelector("input[value='cb1']")); checkBox3 = ...


2

If I understand the question, the issue is not so much about parallelized tests as it is about the JUnit runner's policy of reporting failures individually but only reporting successes in aggregate. If you want successes to be reported individually, I suggest you register a custom RunListener. The RunListener will be invoked each time an event occurs ...


2

You didn't say whether you were using Ant or something else. I will assume you are more interested in the "positive and negative" part of the question than how to invoke the JUnit test runner from your build tool. You can register a TestWatcher to monitor what happens during a test run. The JUnit test runner will invoke methods on the TestWatcher when ...


2

If the element you are interacting with is being replaced in the DOM, which appears to be the case since you're getting a stale element exception, you'll need to find the element again rather than re-using the existing one. So for example, you would do this: chrome.findElements(By.tagName("option")).get(0).click(); ...


2

For backend coverage (mostly java), we use Cobertura: http://cobertura.github.io/cobertura/ The developers tend to use Emma, in Eclipse: http://emma.sourceforge.net/ For frontend (JavaScript), I've heard good things about ScriptCover: http://googletesting.blogspot.com/2011/10/scriptcover-makes-javascript-coverage.html Good luck!


1

Three possibilities: The IDE inputs (e.g. arguments and environment variables) are not the same as the command line inputs. You can check that with print statements or logging. The libraries are not the same. I assume you know how to check this. You found a timing problem. To check this, first determine which element is erroring out, then try waiting ...


1

You can match your text, if it is false, you can save the url. Try following: String[] pages = {"http://google.com","http://yahoo.com"}; ArrayList<String> pagesWithoutMeta = new ArrayList<String>(); boolean isMetaPresent= false; for (int i=0;i<pages.length;i++){ String text = ...


1

There is no default provisioning in JUnit to do this the way you want. By using MethodSorters.NAME_ASCENDING you can ensure order by naming tests in alphabetical order as showed in other answer. Alternatively, you can create your own OrderedRunner and an annotation to fix this type of ordering. public class OrderedRunner extends BlockJUnit4ClassRunner { ...


1

Yes, using WebDriverWait is sufficent in the case where you want to know if your code can proceed to next steps (ie some button being visible). There is no point in doing something like wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.menu.navButton"))); ...


1

Hm. Did I understand correctly that you are indeed receiving a timeoutexception? Could you provide any stacktrace? "I know the element is in the DOM as it will pass more often that not. So if I was to run this overnight, it could fail when it would pass 9 times out of 10." This statement is not good enough. The best you can say is that you can ...


1

Inspired by JUnit's experimental ParallelComputer runner I've built my own ParallelSuite and ParallelParameterized runners. Using these runners one can easily parallelize test suites and parameterized tests. ParallelSuite.java public class ParallelSuite extends Suite { public ParallelSuite(Class<?> klass, RunnerBuilder builder) throws ...


1

Use a JUnit Rule. Here are two articles I wrote about how I've used Rules: Using Rules to Influence JUnit Test Execution What JUnit Rules Are Good For



Only top voted, non community-wiki answers of a minimum length are eligible