8、Selenium+python安裝HTMLTestRunner外掛程式

來源:互聯網
上載者:User

標籤:ptime   \n   print   技術分享   ring   selenium   star   2.0   span   

1.開啟網址:http://tungwaiyip.info/software/HTMLTestRunner.html,下載HTMLTestRunner.py

2.copy其HTMLTestRunner.py的內容,在python路徑下的lib包下,建立.py尾碼名的,粘貼copy內容

 

3.若Python版本是2.0,上述操作即可匯入HTMLTestRunner,但是python3存在不同,需要改變以下內容

(1)在94行,將 import StringIO 改成import io

(2)539行 self.outputBuffer = StringIO.StringIO() 要改成self.outputBuffer = io.BytesIO()

(3)定位到642行,if not rmap.has_key(cls): 需要換成 if not cls in rmap:

(4)772行,把 ue = e.decode(‘latin-1‘) 直接改成 ue = e 。

(5)766還有類似的uo = o.decode(‘latin-1‘),改成 uo=o ;

(6)768行的 uo = o ,直接改成 uo = o.decode(‘utf-8‘) 。

(7) 774還有類似的  ue = e, 改成 ue = e.decode(‘utf-8‘)。

(8)到631行,把print的語句修改掉,原來是print >>sys.stderr, ‘\nTime Elapsed: %s‘ % (self.stopTime-self.startTime), 可改成 print(‘\nTime Elapsed: %s‘ % (self.stopTime-self.startTime),file=sys.stderr)

(9)定位到118行,把 self.fp.write(s) 修改為 self.fp.write(bytes(s,‘UTF-8‘)) 即可。

4.做完以上操作即可,成功的標誌後:

 

8、Selenium+python安裝HTMLTestRunner外掛程式

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.