While writing functional test cases using selenium tearDown() method is one of the greatest functionality/place to do all cleanup actions. This method called immediately after the test method has been called and the result recorded. This is called even if the test method raised an exception, so the implementation in subclasses may need to be particularly careful about checking internal state. Any exception raised by this method will be considered an error rather than a test failure. This method will only be called if the setUp() succeeds, regardless of the outcome of the test method. The default implementation does nothing.
So instead of adding screenshots functionality in each test cases, we can add this functionality in tearDown method as follows:
def tearDown(self):
if sys.exc_info()[0]:
test_method_name = self._testMethodName
now = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
self.driver.save_screenshot(os.getcwd() +'/screenshots/' + test_method_name + "-" + now + ".png")
--Make sure to import following packages for above code.
from selenium import webdriver from datetime import datetime import os
The future of software testing is on positive note. It offers huge career prospects for talented professionals to be skilled software testers. Software testing training institutes
ReplyDeleteThanks for your informative article on UFT automation testing tool. Your post helped me to understand the features and functionality of QTP automation testing tool. QTP Training in Chennai | QTP training
ReplyDeleteTesting is the only way to deliver reliable products in the Information Technology market. Articles like this are vital in improvising one's ability as a software testing professional. Thank you so much for sharing this information in here. Keep blogging.
ReplyDeleteSoftware testing training in chennai | Software testing course | Software testing training institutes in chennai | Software testing training institute in chennai
Automation will make any work to be completed so soon(Selenium training in chennai), in addition to this recording the actions is possible with automated tool. Your content explicitely states the same(Selenium testing training). Thanks for sharing this worth able content in here. This was very useful to me as well. Keep blogging like this(Selenium testing tool training chennai).
ReplyDeleteExcellent post. Hi everyone, I did Selenium Training in Chennai at a leading training institute.Its really useful for me to know more details about selenium testing. Now I am working as a software tester. So join this institute and get bright future.
ReplyDeleteReally interesting content which is unique which provided me the required information.
ReplyDeleteSelenium Training in Chennai | best selenium testing training institute in Chennai.
Selenium is a testing tool which is an open source which can work very well for the professionals and for testers. If a profesional is knowing manual testing then if he learn seenium then there are good chance for career growth.
ReplyDeleteselenium training in chennai | selenium training institute in chennai | selenium course in chennai
Manual testing is the process of testing the software manually in order to detect the software defects. It requires the role of tester to deliver the product efficiently to the customer and use all of its application to ensure that it works correctly
ReplyDeletemanual testing training institute in chennai | manual testing training
Testing now a days has become as importnant as developing of an application. With the help of testing, we can find out the potential bugs which would affect the application. Fixing this at a very early stage would help the application to run without any problem.
ReplyDeleteSoftware testing training in Chennai | Software testing training institute in Chennai | Software testing courses in Chennai
Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
ReplyDeletedigital marketing course in Chennai | digital marketing training in Chennai
The content you posted helps me to get the in depth knowledge about the various technology and it is very interesting to go through it. Thanks for sharing it.
ReplyDeleteAngularJS Training in Chennai | AngularJS course in Chennai
A debt of gratitude is in order for requiring some serious energy share this post. It is truly useful. I propose to visit this site to my group members. Please continue posting this way.
ReplyDeleteRegards,
Selenium Training in Chennai | Selenium Testing Training in Chennai | Selenium Course in Chennai
Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
ReplyDeleteSalesforce Training in Chennai | Salesforce Training Institute in Chennai