Test report for Python conversion Rebot

Source: Internet
Author: User

#!/usr/bin/env python
#-*-Coding:utf-8-*-

Import Os,sys,time
From seleniumImport Webdriver
From Selenium.common.exceptionsImport Nosuchelementexception
From Selenium.webdriver.common.keysImport Keys

Class Get_trandlation (Object):
Def__INT__ (Self,report_path):
Self.report_path=report_path
Def Get_tran (Self,report_path):
Browser = Webdriver. Chrome ()
Browser.get (Report_path)
Detailcontent=browser.find_element_by_xpath ("//table[@class = ' details ']"). Text
TOTALCONTENT=BROWSER.FIND_ELEMENT_BY_ID ("Total-stats"). Text
TAGCONTENT=BROWSER.FIND_ELEMENT_BY_ID ("Tag-stats"). Text
SUITECONTENT=BROWSER.FIND_ELEMENT_BY_ID ("Suite-stats"). Text
Total=browser.find_element_by_xpath ("//*[@id = ' total-stats ']/tbody/tr[1]/td[2]"). Text
Pass_t=browser.find_element_by_xpath ("//*[@id = ' total-stats ']/tbody/tr[1]/td[3]"). Text
details='%.2f%% '% (Int (pass_t)/Int (total) *100)
Return detailcontent,totalcontent,tagcontent,suitecontent,total,pass_t,details
Class CreateReport (get_trandlation):
Def__INIT__ (Self,report_path,reportsavepath):
Self.report_path=report_path
s=Self.get_tran (Report_path)
Print s[0], s[6]
detailcontent=s[0]
totalcontent=s[1]
tagcontent=s[2]
suitecontent=s[3]
total=s[4]
pass_t=s[5]
details=s[6]
Self.detailcontent=detailcontent
Self.totalcontent=totalcontent
Self. Tagcontent=tagcontent
Self.bysuitecontent=suitecontent
Self.total=total
self.pass_t=pass_t
Self.percentage=details
Self.percentage=reportsavepath
Def createreportcontent (SelfReport_path,reportsavepath):
result=Self.detailContent.split ("\ n")
Sdetail=‘‘
For indexInchRangeLen (Result)):
if (index!=Len (Result)):
sdetail=sdetail+result[index]+"<br>"
Else
Sdetail=sdetail+result[index]
Print result
PrintType (Result)
PrintLen (Result)
detailtable="<font size= ' 5 ' style= ' font-weight:bold ' >summary information</font><br><table width= ' 1000 ' Border= ' 1 ' cellpadding= ' 1 ' cellspacing= ' 1 ' ><tr><td width= ' 100% ' > ' +' Run Pass rate: ' +Self.percentage+"</td></tr><tr><td width= ' 100% ' >" +sdetail+"</td></tr></table>"

totaltable="<table width= ' border= ' 1 ' cellpadding= ' 1 ' cellspacing= ' 1 ' ><tr bgcolor= ' #DCDCDC ' ><td width= ' 40% ' ' >total statistics</td><td>total</td><td>pass</td><td>fail</td> <td>Elapsed</td><td>Pass/Fail</td></tr> "
result=Self.totalContent.split ("\ n")
Del result[0]
Del result[0]
Del result[0]
Del result[0]
Del result[0]
Del result[0]
For indexInchRangeLen (Result)):
if ((index+1)%2==1):
Totaltable=totaltable+"<tr><td>" +result[index]+"</td>"
Else
S=result[index]
Items=s.split (" ")
For itemIn items:
Totaltable=totaltable+"<td>" +item+"</td>"
Scolor="";
if (items[2]=="0"):
Scolor="Green"
Else
Scolor="Red"
Totaltable=totaltable+"<td><center><font style= ' Font-weight:bold;color:green ' >" +items[1]+"/</font><font style= ' Font-weight:bold;color:" +scolor+"' >" +items[2]+"</font></center></td></tr>"
Totaltable=totaltable+"</table>"
bytagtable="<table width= ' border= ' 1 ' cellpadding= ' 1 ' cellspacing= ' 1 ' ><tr bgcolor= ' #DCDCDC ' ><td width= ' 40% ' >statistics by tag</td><td>total</td><td>pass</td><td>fail</td>< Td>elapsed</td><td>pass/fail</td></tr> "
result=Self.byTagContent.split ("\ n")
Del result[0]
Del result[0]
Del result[0]
Del result[0]
Del result[0]
Del result[0]
For indexInchRangeLen (Result)):
if ((index+1)%2==1):
Bytagtable=bytagtable+"<tr><td>" +result[index]+"</td>"
Else
S=result[index]
Items=s.split (" ")
For itemIn items:
Bytagtable=bytagtable+"<td>" +item+"</td>"
Scolor="";
if (items[2]=="0"):
Scolor="Green"
Else
Scolor="Red"
Bytagtable=bytagtable+"<td><center><font style= ' Font-weight:bold;color:green ' >" +items[1]+"/</font><font style= ' Font-weight:bold;color:" +scolor+"' >" +items[2]+"</font></center></td></tr>"
Bytagtable=bytagtable+"</table>"
bysuitetable="<table width= ' border= ' 1 ' cellpadding= ' 1 ' cellspacing= ' 1 ' ><tr bgcolor= ' #DCDCDC ' ><td width= ' 40% ' >statistics by suite</td><td>total</td><td>pass</td><td>fail</td> <td>Elapsed</td><td>Pass/Fail</td></tr> "
result=Self.bySuiteContent.split ("\ n") del result[0] del result[0] del result[0] del result[0] del result[0] del result[0] for index in range (len (result)): if ((index+1)%2==1): Bysuitetable=bysuitetable+ "<tr><td>" +result[index]+ "</td>" else:s=result[ Index] Items=s.split ("") for item in Items:bysuitetable=bysuitetable+ "<td>" +item+ "</td>" scolor= ""; if (items[2]== "0"): scolor= "green" else:scolor= "Red" bysuitetable=bysuitetable+ "<td><center><font style= ' Font-weight:bold;color:green ' > ' +items[1]+ '/</font><font style= ' font-weight:bold;color: ' + scolor+ "' >" +items[2]+ "</font></center></td></tr>" Bysuitetable=bysuitetable+ "</ Table> "html="

Python conversion rebot test report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.