{"id":5940,"date":"2021-09-03T08:38:22","date_gmt":"2021-09-03T08:38:22","guid":{"rendered":"https:\/\/www.devstringx.com\/?p=5940"},"modified":"2025-06-30T09:59:24","modified_gmt":"2025-06-30T09:59:24","slug":"multiple-methods-in-selenium-java","status":"publish","type":"post","link":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java","title":{"rendered":"How To Get The Execution Time Of Multiple Methods In Selenium Java? | Devstringx"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Before executing the below code, confirm that pom is updated with the specified dependencies or add the required jars to Java build path.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We are using the Stopwatch of Apache Commons Lang to count the duration and reporter to log messages which will be included within the HTML reports generated by TestNG. It is necessary to install the TestNG plugin in your IDE.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Add dependencies to the pom.xml of the Maven project or download the jars and add them to JAVA build path of the JAVA project.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">import org.apache.commons.lang.time.StopWatch;\r\n\r\nimport org.testng.Reporter;\r\n\r\npublic class stopwatchtime extends StopWatch {\r\n\r\nstatic StopWatch stopwatch = new StopWatch();\r\n\r\npublic static void timetaken(){\r\n\r\nlong x = stopwatch.getTime();\r\n\r\n\/\/ Convert the result to a string\r\n\r\nString numberAsString = Long.toString(x);\r\n\r\nSystem.out.println(\"Execution time for this method- \" +numberAsString+ \" milliseconds \\n\");\r\n\r\nReporter.log(\"Time taken to execute this method- \"+numberAsString+\" milliseconds \\n\" );\r\n\r\n}\r\n\r\npublic static void start(String methodname) {\r\n\r\nstopwatch.start();\r\n\r\nReporter.log(methodname+\"; \\n\");\r\n\r\n}\r\n\r\npublic static void stop(String methodname) {\r\n\r\nstopwatch.stop();\r\n\r\nReporter.log(methodname+ \"; \\n\");\r\n\r\n}\r\n\r\npublic static void reset(String methodname) {\r\n\r\nstopwatch.reset();\r\n\r\nReporter.log(methodname+\"; \\n\");\r\n\r\n}\r\n\r\n}\r\n\r\n}<\/pre>\n<blockquote><p><strong><span style=\"font-size: 20px;\"><em>Read Also:- <a href=\"https:\/\/www.devstringx.com\/integrate-extent-report-selenium-framework\" target=\"_blank\" rel=\"noopener\">Integrate Extent Report within NUnit Selenium Framework Screenshots<\/a><\/em><\/span><\/strong><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Make sure that you simply have added this code to a separate class \u201cstopwatch time\u201d inside the package where you would like to perform these actions.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now you&#8217;ll call these functions multiple times in your main code inside the same package:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">stopwatchtime.reset(\"timer reset\");\r\n\r\nstopwatchtime.start(\"timer started\");\r\n\r\nstopwatchtime.stop(\"timer stopped\");\r\n\r\nstopwatchtime.timetaken();<\/pre>\n<p><span style=\"font-weight: 400;\">To get the execution time of a selected method, call the above functions inside that method in the same fashion.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can find the log messages within the generated TestNG report i.e. index.html or emailable-report.html<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before executing the below code, confirm that pom is updated with the specified dependencies or add the required jars to Java build path. We are using the Stopwatch of Apache Commons Lang to count the duration and reporter to log messages which will be included within the HTML reports generated by TestNG. It is necessary [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":5941,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_case_study_category":"","footnotes":""},"categories":[1],"tags":[376,354],"class_list":["post-5940","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-testing","tag-java","tag-selenium-java"],"featured_image_src":{"landsacpe":["https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium-1140x445.jpg",1140,445,true],"list":["https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium-463x348.jpg",463,348,true],"medium":["https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium-300x150.jpg",300,150,true],"full":["https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium.jpg",1430,715,false]},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Get The Execution Time Of Multiple Methods In Selenium Java?<\/title>\n<meta name=\"description\" content=\"In this blog we share step by step about execution time of multiple methods in selenium java. Devstringx Technologies\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Get The Execution Time Of Multiple Methods In Selenium Java?\" \/>\n<meta property=\"og:description\" content=\"In this blog we share step by step about execution time of multiple methods in selenium java. Devstringx Technologies\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java\" \/>\n<meta property=\"og:site_name\" content=\"Devstringx Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/devstringx\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-03T08:38:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-30T09:59:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1430\" \/>\n\t<meta property=\"og:image:height\" content=\"715\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mukul Bhatnagar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DevstringXS\" \/>\n<meta name=\"twitter:site\" content=\"@DevstringXS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mukul Bhatnagar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java\"},\"author\":{\"name\":\"Mukul Bhatnagar\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#\\\/schema\\\/person\\\/0cd349a079de3fbafd46670445bf5780\"},\"headline\":\"How To Get The Execution Time Of Multiple Methods In Selenium Java? | Devstringx\",\"datePublished\":\"2021-09-03T08:38:22+00:00\",\"dateModified\":\"2025-06-30T09:59:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java\"},\"wordCount\":192,\"publisher\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/Selenium.jpg\",\"keywords\":[\"java\",\"Selenium java\"],\"articleSection\":[\"Testing\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java\",\"url\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java\",\"name\":\"How To Get The Execution Time Of Multiple Methods In Selenium Java?\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/Selenium.jpg\",\"datePublished\":\"2021-09-03T08:38:22+00:00\",\"dateModified\":\"2025-06-30T09:59:24+00:00\",\"description\":\"In this blog we share step by step about execution time of multiple methods in selenium java. Devstringx Technologies\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/multiple-methods-in-selenium-java#primaryimage\",\"url\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/Selenium.jpg\",\"contentUrl\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/Selenium.jpg\",\"width\":1430,\"height\":715,\"caption\":\"Selenium Java\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#website\",\"url\":\"https:\\\/\\\/www.devstringx.com\\\/\",\"name\":\"Devstringx Technologies\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.devstringx.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#organization\",\"name\":\"Devstringx Technologies\",\"url\":\"https:\\\/\\\/www.devstringx.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/Devstringx-logo-black-png.png\",\"contentUrl\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/Devstringx-logo-black-png.png\",\"width\":504,\"height\":129,\"caption\":\"Devstringx Technologies\"},\"image\":{\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/devstringx\",\"https:\\\/\\\/x.com\\\/DevstringXS\",\"https:\\\/\\\/www.instagram.com\\\/devstringx\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/devstringx-technologies-pvt-ltd-?trk=tyah&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;trkInfo=tarId:1399698650897,tas:devstringx,idx:1-1-1\",\"https:\\\/\\\/devstringx-technologies.medium.com\\\/\",\"https:\\\/\\\/www.pinterest.com\\\/devstringx\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCI13h4Nar01RtsW0oZrhzoA\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/#\\\/schema\\\/person\\\/0cd349a079de3fbafd46670445bf5780\",\"name\":\"Mukul Bhatnagar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Bloger-Mukul-96x96.jpg\",\"url\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Bloger-Mukul-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/www.devstringx.com\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Bloger-Mukul-96x96.jpg\",\"caption\":\"Mukul Bhatnagar\"},\"description\":\"Accomplished Software Tester gained hands-on experience with various Software Testing tools. Skilled in Unit testing with documentation and test case validation right from apps to jets. \\\"Writing effective test cases is a skill and following the best approach is a key\\\" - Mukul Bhatnagar\",\"sameAs\":[\"https:\\\/\\\/www.devstringx.com\"],\"url\":\"https:\\\/\\\/www.devstringx.com\\\/author\\\/mukulbhatnagar\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Get The Execution Time Of Multiple Methods In Selenium Java?","description":"In this blog we share step by step about execution time of multiple methods in selenium java. Devstringx Technologies","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java","og_locale":"en_US","og_type":"article","og_title":"How To Get The Execution Time Of Multiple Methods In Selenium Java?","og_description":"In this blog we share step by step about execution time of multiple methods in selenium java. Devstringx Technologies","og_url":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java","og_site_name":"Devstringx Technologies","article_publisher":"https:\/\/www.facebook.com\/devstringx","article_published_time":"2021-09-03T08:38:22+00:00","article_modified_time":"2025-06-30T09:59:24+00:00","og_image":[{"width":1430,"height":715,"url":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium.jpg","type":"image\/jpeg"}],"author":"Mukul Bhatnagar","twitter_card":"summary_large_image","twitter_creator":"@DevstringXS","twitter_site":"@DevstringXS","twitter_misc":{"Written by":"Mukul Bhatnagar","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java#article","isPartOf":{"@id":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java"},"author":{"name":"Mukul Bhatnagar","@id":"https:\/\/www.devstringx.com\/#\/schema\/person\/0cd349a079de3fbafd46670445bf5780"},"headline":"How To Get The Execution Time Of Multiple Methods In Selenium Java? | Devstringx","datePublished":"2021-09-03T08:38:22+00:00","dateModified":"2025-06-30T09:59:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java"},"wordCount":192,"publisher":{"@id":"https:\/\/www.devstringx.com\/#organization"},"image":{"@id":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java#primaryimage"},"thumbnailUrl":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium.jpg","keywords":["java","Selenium java"],"articleSection":["Testing"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java","url":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java","name":"How To Get The Execution Time Of Multiple Methods In Selenium Java?","isPartOf":{"@id":"https:\/\/www.devstringx.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java#primaryimage"},"image":{"@id":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java#primaryimage"},"thumbnailUrl":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium.jpg","datePublished":"2021-09-03T08:38:22+00:00","dateModified":"2025-06-30T09:59:24+00:00","description":"In this blog we share step by step about execution time of multiple methods in selenium java. Devstringx Technologies","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devstringx.com\/multiple-methods-in-selenium-java#primaryimage","url":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium.jpg","contentUrl":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2021\/10\/Selenium.jpg","width":1430,"height":715,"caption":"Selenium Java"},{"@type":"WebSite","@id":"https:\/\/www.devstringx.com\/#website","url":"https:\/\/www.devstringx.com\/","name":"Devstringx Technologies","description":"","publisher":{"@id":"https:\/\/www.devstringx.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devstringx.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.devstringx.com\/#organization","name":"Devstringx Technologies","url":"https:\/\/www.devstringx.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devstringx.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2024\/12\/Devstringx-logo-black-png.png","contentUrl":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2024\/12\/Devstringx-logo-black-png.png","width":504,"height":129,"caption":"Devstringx Technologies"},"image":{"@id":"https:\/\/www.devstringx.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/devstringx","https:\/\/x.com\/DevstringXS","https:\/\/www.instagram.com\/devstringx\/","https:\/\/www.linkedin.com\/company\/devstringx-technologies-pvt-ltd-?trk=tyah&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;trkInfo=tarId:1399698650897,tas:devstringx,idx:1-1-1","https:\/\/devstringx-technologies.medium.com\/","https:\/\/www.pinterest.com\/devstringx\/","https:\/\/www.youtube.com\/channel\/UCI13h4Nar01RtsW0oZrhzoA"]},{"@type":"Person","@id":"https:\/\/www.devstringx.com\/#\/schema\/person\/0cd349a079de3fbafd46670445bf5780","name":"Mukul Bhatnagar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2022\/02\/Bloger-Mukul-96x96.jpg","url":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2022\/02\/Bloger-Mukul-96x96.jpg","contentUrl":"https:\/\/www.devstringx.com\/wp-content\/uploads\/2022\/02\/Bloger-Mukul-96x96.jpg","caption":"Mukul Bhatnagar"},"description":"Accomplished Software Tester gained hands-on experience with various Software Testing tools. Skilled in Unit testing with documentation and test case validation right from apps to jets. \"Writing effective test cases is a skill and following the best approach is a key\" - Mukul Bhatnagar","sameAs":["https:\/\/www.devstringx.com"],"url":"https:\/\/www.devstringx.com\/author\/mukulbhatnagar"}]}},"_links":{"self":[{"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/posts\/5940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/comments?post=5940"}],"version-history":[{"count":0,"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/posts\/5940\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/media\/5941"}],"wp:attachment":[{"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/media?parent=5940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/categories?post=5940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devstringx.com\/wp-json\/wp\/v2\/tags?post=5940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}