Chrome won't quit after assertion error occurs'Must Override a Superclass Method' Errors after importing a project into EclipseChrome driver doesn't quit after capybara testERROR: HHH000099: an assertion failure occuredSelenium webdriver does not quit chrome driverNoSuchElement Exception (selenium)Selenium: org.openqa.selenium.NoSuchWindowException: Currently focused window has been closedChrome processes are not killed after using quit() method on Chrome 65Selenium example using Node.js from MDN not working?how can i close iframe popup in seleniumpython chromedirver won't quit

Coworker mumbles to herself when working, how to ask her to stop?

Find all the numbers in one file that are not in another file in python

What is a good example for artistic ND filter applications?

Why didn't Stark and Nebula use jump points with their ship to go back to Earth?

Is Ear Protection Necessary For General Aviation Airplanes?

Is it unprofessional to mention your cover letter and resume are best viewed in Chrome?

How to have poached eggs in "sphere form"?

What language is Raven using for her attack in the new 52?

On what tickets or flights are Flying Blue XP earned?

How to efficiently shred a lot of cabbage?

How do you deal with characters with multiple races?

Should I intervene when a colleague in a different department makes students run laps as part of their grade?

PCB design using code instead of clicking a mouse?

Why are subdominants unstable?

Was the Psych theme song written for the show?

Does Ubuntu reduce battery life?

What Marvel character has this 'W' symbol?

Are all French verb conjugation tenses and moods practical and efficient?

Why are we moving in circles with a tandem kayak?

How to prevent a single-element caster from being useless against immune foes?

Why don't short runways use ramps for takeoff?

Rampant sharing of authorship among colleagues in the name of "collaboration". Is not taking part in it a death knell for a future in academia?

How can flights operated by the same company have such different prices when marketed by another?

Can I attune a Circlet of Human Perfection to my animated skeletons to allow them to blend in and speak?



Chrome won't quit after assertion error occurs


'Must Override a Superclass Method' Errors after importing a project into EclipseChrome driver doesn't quit after capybara testERROR: HHH000099: an assertion failure occuredSelenium webdriver does not quit chrome driverNoSuchElement Exception (selenium)Selenium: org.openqa.selenium.NoSuchWindowException: Currently focused window has been closedChrome processes are not killed after using quit() method on Chrome 65Selenium example using Node.js from MDN not working?how can i close iframe popup in seleniumpython chromedirver won't quit






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm trying to get the browser to close when the test fails via assertion.



It outputs the correct log info in the log, but the browser does not close.



java.lang.AssertionError: Error: Title is 'Jordan | TolaActivity', and should be Country Name | TolaActivity



at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at Tola.Activity.tests.LoginPage.Login(LoginPage.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at


 @Test
// Test Case # 1: User can login successfuly
//

public void Login() throws Exception TolaActivity", driver.getTitle().contains("asdasd"));

driver.quit();


}









share|improve this question





















  • 1





    If assertTrue throws an exception then driver.quit() won't be called. You could use a try-finally block, but since you're using JUnit you could also use before/after methods.

    – Slaw
    Mar 26 at 21:24












  • Im not the most experienced developer, could you provide an example using my code? I've tried a catch, successfuly closes the browser but it says the test passed, even though the assertion was actually not true

    – Rickie Thornley
    Mar 26 at 21:28











  • As this is dealing with unit testing, there's no reason to have a catch. Just use try-finally: try /* test code */ finally driver.quit(); . If, however, you do need a catch as well, simply re-throw the exception. And depending on your use case, you might want to consider using "test fixtures" (← link points to JUnit 4, if you ever upgrade to JUnit 5, see the user guide).

    – Slaw
    Mar 26 at 22:26


















0















I'm trying to get the browser to close when the test fails via assertion.



It outputs the correct log info in the log, but the browser does not close.



java.lang.AssertionError: Error: Title is 'Jordan | TolaActivity', and should be Country Name | TolaActivity



at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at Tola.Activity.tests.LoginPage.Login(LoginPage.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at


 @Test
// Test Case # 1: User can login successfuly
//

public void Login() throws Exception TolaActivity", driver.getTitle().contains("asdasd"));

driver.quit();


}









share|improve this question





















  • 1





    If assertTrue throws an exception then driver.quit() won't be called. You could use a try-finally block, but since you're using JUnit you could also use before/after methods.

    – Slaw
    Mar 26 at 21:24












  • Im not the most experienced developer, could you provide an example using my code? I've tried a catch, successfuly closes the browser but it says the test passed, even though the assertion was actually not true

    – Rickie Thornley
    Mar 26 at 21:28











  • As this is dealing with unit testing, there's no reason to have a catch. Just use try-finally: try /* test code */ finally driver.quit(); . If, however, you do need a catch as well, simply re-throw the exception. And depending on your use case, you might want to consider using "test fixtures" (← link points to JUnit 4, if you ever upgrade to JUnit 5, see the user guide).

    – Slaw
    Mar 26 at 22:26














0












0








0








I'm trying to get the browser to close when the test fails via assertion.



It outputs the correct log info in the log, but the browser does not close.



java.lang.AssertionError: Error: Title is 'Jordan | TolaActivity', and should be Country Name | TolaActivity



at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at Tola.Activity.tests.LoginPage.Login(LoginPage.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at


 @Test
// Test Case # 1: User can login successfuly
//

public void Login() throws Exception TolaActivity", driver.getTitle().contains("asdasd"));

driver.quit();


}









share|improve this question
















I'm trying to get the browser to close when the test fails via assertion.



It outputs the correct log info in the log, but the browser does not close.



java.lang.AssertionError: Error: Title is 'Jordan | TolaActivity', and should be Country Name | TolaActivity



at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at Tola.Activity.tests.LoginPage.Login(LoginPage.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at


 @Test
// Test Case # 1: User can login successfuly
//

public void Login() throws Exception TolaActivity", driver.getTitle().contains("asdasd"));

driver.quit();


}






java selenium






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 21:24









Zabuza

13k6 gold badges31 silver badges45 bronze badges




13k6 gold badges31 silver badges45 bronze badges










asked Mar 26 at 21:22









Rickie ThornleyRickie Thornley

1




1










  • 1





    If assertTrue throws an exception then driver.quit() won't be called. You could use a try-finally block, but since you're using JUnit you could also use before/after methods.

    – Slaw
    Mar 26 at 21:24












  • Im not the most experienced developer, could you provide an example using my code? I've tried a catch, successfuly closes the browser but it says the test passed, even though the assertion was actually not true

    – Rickie Thornley
    Mar 26 at 21:28











  • As this is dealing with unit testing, there's no reason to have a catch. Just use try-finally: try /* test code */ finally driver.quit(); . If, however, you do need a catch as well, simply re-throw the exception. And depending on your use case, you might want to consider using "test fixtures" (← link points to JUnit 4, if you ever upgrade to JUnit 5, see the user guide).

    – Slaw
    Mar 26 at 22:26













  • 1





    If assertTrue throws an exception then driver.quit() won't be called. You could use a try-finally block, but since you're using JUnit you could also use before/after methods.

    – Slaw
    Mar 26 at 21:24












  • Im not the most experienced developer, could you provide an example using my code? I've tried a catch, successfuly closes the browser but it says the test passed, even though the assertion was actually not true

    – Rickie Thornley
    Mar 26 at 21:28











  • As this is dealing with unit testing, there's no reason to have a catch. Just use try-finally: try /* test code */ finally driver.quit(); . If, however, you do need a catch as well, simply re-throw the exception. And depending on your use case, you might want to consider using "test fixtures" (← link points to JUnit 4, if you ever upgrade to JUnit 5, see the user guide).

    – Slaw
    Mar 26 at 22:26








1




1





If assertTrue throws an exception then driver.quit() won't be called. You could use a try-finally block, but since you're using JUnit you could also use before/after methods.

– Slaw
Mar 26 at 21:24






If assertTrue throws an exception then driver.quit() won't be called. You could use a try-finally block, but since you're using JUnit you could also use before/after methods.

– Slaw
Mar 26 at 21:24














Im not the most experienced developer, could you provide an example using my code? I've tried a catch, successfuly closes the browser but it says the test passed, even though the assertion was actually not true

– Rickie Thornley
Mar 26 at 21:28





Im not the most experienced developer, could you provide an example using my code? I've tried a catch, successfuly closes the browser but it says the test passed, even though the assertion was actually not true

– Rickie Thornley
Mar 26 at 21:28













As this is dealing with unit testing, there's no reason to have a catch. Just use try-finally: try /* test code */ finally driver.quit(); . If, however, you do need a catch as well, simply re-throw the exception. And depending on your use case, you might want to consider using "test fixtures" (← link points to JUnit 4, if you ever upgrade to JUnit 5, see the user guide).

– Slaw
Mar 26 at 22:26






As this is dealing with unit testing, there's no reason to have a catch. Just use try-finally: try /* test code */ finally driver.quit(); . If, however, you do need a catch as well, simply re-throw the exception. And depending on your use case, you might want to consider using "test fixtures" (← link points to JUnit 4, if you ever upgrade to JUnit 5, see the user guide).

– Slaw
Mar 26 at 22:26













2 Answers
2






active

oldest

votes


















1














You need to utilize some sort of error handling. An exception is being thrown from your assert and is not being handled, so your following quit is never called. Here is one example - Depending on your project structure you might want to do it higher up in your call hierarchy.



 public void Login() throws Exception 

try TolaActivity", driver.getTitle().contains("asdasd"));

catch(/*Your assert exception */)
///Handle an error here if you want to do something more

finally
driver.quit();







share|improve this answer

























  • When i try it this way, the assertion fails but it still "passes" the test?

    – Rickie Thornley
    Mar 26 at 21:36











  • In that case you have to re-throw the exception inside the catch clause to make it fail.

    – Thomas Hirsch
    Mar 26 at 21:41



















1














Create a method that gets run after your test method which will quit the driver. This will close your driver after everything in your test method has run.



@After
public void teardown()
this.driver.quit()






share|improve this answer

























  • Since Assert.assertTrue("value"); statement has specific meaning which you should not handle, better use @AfterMethod(alwaysRun = true) to quit the browser

    – Govardhan Sriramdasu
    Mar 27 at 7:49













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366388%2fchrome-wont-quit-after-assertion-error-occurs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You need to utilize some sort of error handling. An exception is being thrown from your assert and is not being handled, so your following quit is never called. Here is one example - Depending on your project structure you might want to do it higher up in your call hierarchy.



 public void Login() throws Exception 

try TolaActivity", driver.getTitle().contains("asdasd"));

catch(/*Your assert exception */)
///Handle an error here if you want to do something more

finally
driver.quit();







share|improve this answer

























  • When i try it this way, the assertion fails but it still "passes" the test?

    – Rickie Thornley
    Mar 26 at 21:36











  • In that case you have to re-throw the exception inside the catch clause to make it fail.

    – Thomas Hirsch
    Mar 26 at 21:41
















1














You need to utilize some sort of error handling. An exception is being thrown from your assert and is not being handled, so your following quit is never called. Here is one example - Depending on your project structure you might want to do it higher up in your call hierarchy.



 public void Login() throws Exception 

try TolaActivity", driver.getTitle().contains("asdasd"));

catch(/*Your assert exception */)
///Handle an error here if you want to do something more

finally
driver.quit();







share|improve this answer

























  • When i try it this way, the assertion fails but it still "passes" the test?

    – Rickie Thornley
    Mar 26 at 21:36











  • In that case you have to re-throw the exception inside the catch clause to make it fail.

    – Thomas Hirsch
    Mar 26 at 21:41














1












1








1







You need to utilize some sort of error handling. An exception is being thrown from your assert and is not being handled, so your following quit is never called. Here is one example - Depending on your project structure you might want to do it higher up in your call hierarchy.



 public void Login() throws Exception 

try TolaActivity", driver.getTitle().contains("asdasd"));

catch(/*Your assert exception */)
///Handle an error here if you want to do something more

finally
driver.quit();







share|improve this answer













You need to utilize some sort of error handling. An exception is being thrown from your assert and is not being handled, so your following quit is never called. Here is one example - Depending on your project structure you might want to do it higher up in your call hierarchy.



 public void Login() throws Exception 

try TolaActivity", driver.getTitle().contains("asdasd"));

catch(/*Your assert exception */)
///Handle an error here if you want to do something more

finally
driver.quit();








share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 26 at 21:29









SevitomTheOgreSevitomTheOgre

344 bronze badges




344 bronze badges















  • When i try it this way, the assertion fails but it still "passes" the test?

    – Rickie Thornley
    Mar 26 at 21:36











  • In that case you have to re-throw the exception inside the catch clause to make it fail.

    – Thomas Hirsch
    Mar 26 at 21:41


















  • When i try it this way, the assertion fails but it still "passes" the test?

    – Rickie Thornley
    Mar 26 at 21:36











  • In that case you have to re-throw the exception inside the catch clause to make it fail.

    – Thomas Hirsch
    Mar 26 at 21:41

















When i try it this way, the assertion fails but it still "passes" the test?

– Rickie Thornley
Mar 26 at 21:36





When i try it this way, the assertion fails but it still "passes" the test?

– Rickie Thornley
Mar 26 at 21:36













In that case you have to re-throw the exception inside the catch clause to make it fail.

– Thomas Hirsch
Mar 26 at 21:41






In that case you have to re-throw the exception inside the catch clause to make it fail.

– Thomas Hirsch
Mar 26 at 21:41














1














Create a method that gets run after your test method which will quit the driver. This will close your driver after everything in your test method has run.



@After
public void teardown()
this.driver.quit()






share|improve this answer

























  • Since Assert.assertTrue("value"); statement has specific meaning which you should not handle, better use @AfterMethod(alwaysRun = true) to quit the browser

    – Govardhan Sriramdasu
    Mar 27 at 7:49















1














Create a method that gets run after your test method which will quit the driver. This will close your driver after everything in your test method has run.



@After
public void teardown()
this.driver.quit()






share|improve this answer

























  • Since Assert.assertTrue("value"); statement has specific meaning which you should not handle, better use @AfterMethod(alwaysRun = true) to quit the browser

    – Govardhan Sriramdasu
    Mar 27 at 7:49













1












1








1







Create a method that gets run after your test method which will quit the driver. This will close your driver after everything in your test method has run.



@After
public void teardown()
this.driver.quit()






share|improve this answer













Create a method that gets run after your test method which will quit the driver. This will close your driver after everything in your test method has run.



@After
public void teardown()
this.driver.quit()







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 26 at 21:56









RKelleyRKelley

4713 silver badges12 bronze badges




4713 silver badges12 bronze badges















  • Since Assert.assertTrue("value"); statement has specific meaning which you should not handle, better use @AfterMethod(alwaysRun = true) to quit the browser

    – Govardhan Sriramdasu
    Mar 27 at 7:49

















  • Since Assert.assertTrue("value"); statement has specific meaning which you should not handle, better use @AfterMethod(alwaysRun = true) to quit the browser

    – Govardhan Sriramdasu
    Mar 27 at 7:49
















Since Assert.assertTrue("value"); statement has specific meaning which you should not handle, better use @AfterMethod(alwaysRun = true) to quit the browser

– Govardhan Sriramdasu
Mar 27 at 7:49





Since Assert.assertTrue("value"); statement has specific meaning which you should not handle, better use @AfterMethod(alwaysRun = true) to quit the browser

– Govardhan Sriramdasu
Mar 27 at 7:49

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366388%2fchrome-wont-quit-after-assertion-error-occurs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript