Error while using ExtentReports in python webdriver script using Jpype -
extentreports can used in selenium java web-driver scripts generate , rich html test report. trying use in selenium python web-driver script using jpype (jpype effort allow python programs full access java class libraries). code
from jpype import * classpath = """lib\\extentreports-2.41.2.jar;lib\\freemarker-2.3.23.jar""" startjvm(getdefaultjvmpath(), "-djava.class.path=%s" % classpath) extentreports = jclass('com.relevantcodes.extentreports.extentreports') extenttest = jclass('com.relevantcodes.extentreports.extenttest') logstatus = jclass('com.relevantcodes.extentreports.logstatus') extent = extentreports("testresult\\test_report.html") test = extent.starttest("my first test", "sample description") test.log(logstatus.info, "this step shows usage of log(logstatus, details)") extent.endtest(test) extent.flush() shutdownjvm()
and give error
traceback (most recent call last): file "c:\users\test\workspace\extentreportsproject\extentreportspackage\report.py", line 4, in <module> extentreports = jclass('com.relevantcodes.extentreports.extentreports') file "c:\program files\python35\lib\site-packages\jpype1-0.6.2-py3.5-win-amd64.egg\jpype\_jclass.py", line 55, in jclass raise _runtimeexception.pyexc("class %s not found" % name) jpype._jexception.runtimeexceptionpyraisable: java.lang.runtimeexception: class com.relevantcodes.extentreports.extentreports not found
i using extentreports-2.41.2.jar , freemarker-2.3.23.jar. python used in 3.5.1 , java 8 update 121
can this?
i got answer. following code work:
from jpype import * classpath = """extentreports-2.40.2.jar;freemarker-2.3.23.jar""" startjvm(getdefaultjvmpath(), "-djava.class.path=%s" % classpath) extentreports = jclass('com.relevantcodes.extentreports.extentreports') extenttest = jclass('com.relevantcodes.extentreports.extenttest') logstatus = jclass('com.relevantcodes.extentreports.logstatus') extent = extentreports("test_report.html") test = extent.starttest("test case 1", "sample description") test.log(logstatus.info, "this step shows usage of log(logstatus, details)") test.log(logstatus.pass, "step passed") extent.flush() test = extent.starttest("test case 2", "sample description") test.log(logstatus.info, "this step shows usage of log(logstatus, details)") test.log(logstatus.pass, "") test.log(logstatus.fail, "step passed") extent.flush() extent.endtest(test) extent.flush() shutdownjvm()
Comments
Post a Comment