java - Maven does not stop on error using selenium webdriver 2 -


i sorry if answered, tried find solution , still not getting anything.

i working in eclipse , selenium webdriver , running code via maven.

my problem maven continues running forever if error found, selenium driver not closed until close browser's window.

i can manually if happens in local, problem when try use jenknins, if fails, jenkins job running until stop it.

can please me?

thanks in advance.

the important thing call webdriver.quit() finish testing.

usually in junit, means calling in 1 of these places:

  • a method or class annotated @after or @afterclass,
  • a property or class annotated @rule or @classrule,
  • a runlistener class, via testfinished() or testrunfinished() methods,
  • a suitable runner class or
  • static teardown code.

you should choose opposite wherever create driver object. if tests selenium webdriver ones , if intend run them sequentially in single browser window (i think common situation smallish projects), single runlistener can hide code nicely. example:

public class webdrivercontext extends runlistener {   public static webdriver driver; // pretending final   public void testrunstarted(description descr) {     driver = new firefoxdriver();   }   public void testrunfinished(result result) {     driver.quit();   } } 

(credit op answer, in comment above. he's apparently gone now, he's not going able post answer here. i've expanded fair bit.)


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -