<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Selenium Webdriver 中的 XSLT 報告 > 原文: [https://www.guru99.com/xslt-report-selenium.html](https://www.guru99.com/xslt-report-selenium.html) 測試報告是 Selenium 框架最重要的功能。 在 Selenium 中, [Testng](/all-about-testng-and-selenium.html) 提供了其默認報告系統。 為了增強報告功能,進一步的 XSLT 報告很有幫助。 它還具有更加用戶友好的 UI 和測試套件結果的詳細描述。 在本教程中,您將學習– * [什么是 XSLT?](#1) * [生成 XSLT 報告的先決條件](#2) * [在硒](#3)中生成 XSLT 報告 * [驗證 XSLT 報告](#4) ## 什么是 XSLT? XSLT 是一種用于將 XML 文檔轉換為瀏覽器使用的其他 XML 文檔(XHTML)的語言。 XSLT 的完整形式是**可擴展樣式表語言轉換**。 使用 XSLT,我們可以自定義輸出文件。 這可以通過在 XML 文件中添加/刪除屬性和元素來完成。 這有助于快速解釋結果。 所有瀏覽器都支持 XSLT。 它使用 [XPath](/xpath-selenium.html) 瀏覽 XML 文檔中的元素和屬性。 以下是編程中最常用的 XSL 元素: * **< xsl:stylesheet >** 定義此文檔為 XSLT 樣式表文檔。 * **< xsl:if >** 用于對 XML 文件的內容進行條件測試。 * **< xsl:template >** 用于構建模板。 * **< xsl:apply-templates >** 用于將模板應用于元素。 * **< xs1:選擇>** 與< xs1 結合使用:否則,>和< xs1:>表示多種條件時使用。 * **< xsl:for-each >** 用于選擇指定節點的每個 XML 元素。 * **< xsl:>的值**用于提取所選節點的值。 * **< xsl:sort >** 用于對輸出進行排序。 ## 生成 XSLT 報告的先決條件 以下是生成 XSLT 報告的前提條件。 1)應該安裝 ANT 構建工具(必須安裝 ANT 才能使用 XSLT 報告功能)。 ANT 用于編譯源代碼并創建內部版本。 它也是非常可擴展的。 請參考此[鏈接](/using-apache-ant-with-selenium.html)以獲取下載和安裝 ANT 的步驟。 2)下載 XSLT 軟件包。 3)應該由 TestNG 執行的 Selenium 腳本。 在此示例中,我們將在 Selenium Webdriver 中討論 XSLT 報告。 ## 在硒中生成 XSLT 報告 在這種情況下,我們將使用 Guru99 演示站點來說明“生成 XSLT”報告。 **場景**:您將針對以下場景自動生成 XSLT 報告 * 啟動網絡瀏覽器 * 啟動 Firefox 并打開站點“ [http://demo.guru99.com/V4/”](http://demo.guru99.com/V4/) ![XSLT Report in Selenium](https://img.kancloud.cn/72/c9/72c93c4cba9db5029ae32e127b2c3a34_296x142.png "XSLT Report in Selenium") * 登錄到該應用程序。 ![XSLT Report in Selenium](https://img.kancloud.cn/54/75/54752f92cbc88fe63ccd301ddf56abea_541x173.png "XSLT Report in Selenium") * Log out from the application. ![XSLT Report in Selenium](https://img.kancloud.cn/16/e1/16e1c5039377ada8c7eef7ab78707cc2_460x172.png "XSLT Report in Selenium") 現在,我們將按照以下步驟在硒中生成 XSLT 報告。 **步驟 1):**對于上述情況。 為 Guru99 演示站點創建并執行 Selenium 腳本。 ``` import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; import org.testng.annotations.Test; public class Testing { WebDriver driver= new FirefoxDriver(); @Test(priority=1) public void Login() { //Launching the Site. driver.get("http://demo.guru99.com/V4/"); //Login to Guru99 driver.findElement(By.name("uid")).sendKeys("mngr34926"); driver.findElement(By.name("password")).sendKeys("amUpenu"); driver.findElement(By.name("btnLogin")).click(); //Verifying the manager home page Assert.assertEquals(driver.getTitle(),"Guru99 Bank Manager HomePage" ); } @Test(priority=2) public void verifytitle() { //Verifying the title of the home page Assert.assertEquals(driver.getTitle(),"Guru99 Bank Manager HomePage" ); } @Test(priority=3) public void Logout() { driver.findElement(By.linkText("Log out")).click(); Alert alert=driver.switchTo().alert(); alert.accept(); //Verifying the title of the logout page Assert.assertEquals(driver.getTitle(),"Guru99 Bank Home Page" ); } } ``` **步驟 2):**從此[鏈接](https://drive.google.com/folderview?id=0B5v_nInLNoquV1p5YWtHc3lkUkU&usp=sharing_eid&ts=5731a400)下載 XSLT 報告包: ![XSLT Report in Selenium](https://img.kancloud.cn/3f/7a/3f7a73efcb6257e4503c32e4e66c07c3_676x155.png "XSLT Report in Selenium") 解壓縮上面的文件夾,您將獲得以下項目: * build.xml * testng-results.xsl ![XSLT Report in Selenium](https://img.kancloud.cn/18/c4/18c422ec8bbdd5306f2491633a16532d_696x294.png "XSLT Report in Selenium") **步驟 3):**解壓縮文件夾并復制所有文件,然后粘貼到項目主目錄中,如下圖所示。 ![XSLT Report in Selenium](https://img.kancloud.cn/4c/28/4c282662b6380a2edfc249b87101e51c_662x301.png "XSLT Report in Selenium") **步驟 4):**在此步驟中,從 eclipse 運行 build.xml 文件,如下所示: ![XSLT Report in Selenium](https://img.kancloud.cn/c1/db/c1db14859df1b40fa35281c8dccf7a73_381x200.png "XSLT Report in Selenium") 右鍵單擊 build.xml,然后單擊“以 Ant 形式運行”。 ![XSLT Report in Selenium](https://img.kancloud.cn/b9/54/b954337319275437dcf058f091b1faea_790x452.png "XSLT Report in Selenium") 然后將打開一個新窗口。 現在選擇選項“ generateReport”。 ![XSLT Report in Selenium](https://img.kancloud.cn/28/17/2817a9e50e18ba6a12b9dc658d141847_674x533.png "XSLT Report in Selenium") 單擊運行按鈕。 它應該生成報告。 ## 驗證 XSLT 報告 一旦構建成功并移至項目主目錄。 您會找到 **testng-xslt** 文件夾。 ![XSLT Report in Selenium](https://img.kancloud.cn/ea/ba/eaba3588fbbf41cd6751e0995100e397_597x266.png "XSLT Report in Selenium") 在此文件夾中,您將找到 **index.html** 文件,如下所示: ![XSLT Report in Selenium](https://img.kancloud.cn/7d/1e/7d1eb75fc81a7df68e7e74d6ab8ea1ed_642x274.png "XSLT Report in Selenium") 現在,在支持 javascript 的任何瀏覽器(如 Firefox 或 Chrome)中打開此 HTML 文件。 您將在以下屏幕中找到報告。 餅圖報告更清楚地表示測試狀態。 過濾功能允許用戶按照設置的標準過濾結果。 ![XSLT Report in Selenium](https://img.kancloud.cn/0e/b1/0eb1257e4eabbfc6d8f57b11ab3cae59_1156x405.png "XSLT Report in Selenium") 您會發現餅圖顯示通過,未通過和跳過的測試的百分比。 要以常規格式顯示結果,請單擊窗格左側的**默認套件**。 它應該顯示每個測試的詳細信息,如以下屏幕所示: ![XSLT Report in Selenium](https://img.kancloud.cn/bf/78/bf78780f1c5a52cec323435eb54923fb_1079x310.png "XSLT Report in Selenium") 現在,我們強制進行測試通過,失敗和跳過。 要查看測試結果的每種類型的報告,我們需要對以下方法進行一些更改。 1. **verifytitle()**:在聲明中,我們傳遞了錯誤的預期頁面標題。 執行代碼時,它與預期的標題不匹配。 因此使測試失敗。 2. **Logout()**:在這種方法中,我們通過使用 skipexception 強制跳過測試。 這樣,當執行代碼時,此方法將被跳過。 這樣,我們試圖在餅圖的幫助下顯示 XSLT 報告。 它將顯示通過,失敗和跳過測試的測試結果。 ``` @Test(priority=2) public void verifytitle() { //Verifying the title of the home page Assert.assertEquals(driver.getTitle(),"Guru99 Bank Manager" ); } ``` ![XSLT Report in Selenium](https://img.kancloud.cn/af/f9/aff9d16d26c2420d796cb86b6198b955_289x176.png "XSLT Report in Selenium") ``` @Test(priority=3) public void Logout() { throw new SkipException("Skip this"); } ``` ![XSLT Report in Selenium](https://img.kancloud.cn/8d/5e/8d5e6e617c60b0f9d399282344fdb7fe_253x182.png "XSLT Report in Selenium") 現在,我們對每種結果狀態(即通過,失敗和跳過)進行一次測試。 執行完腳本和 build.xml 之后。 驗證 XSLT 報告,如以下屏幕所示: ![XSLT Report in Selenium](https://img.kancloud.cn/14/0b/140b12e08c158dc628991a332841123f_1120x379.png "XSLT Report in Selenium") 測試報告是更人性化的報告,易于理解。 您還可以通過選擇以下屏幕中的復選框來過濾結果。 ![XSLT Report in Selenium](https://img.kancloud.cn/be/dc/bedcff7a4f8fe6b04e671e61cdfca37a_1110x322.png "XSLT Report in Selenium") **注意**:在屏幕快照中,“ config”選項顯示已完成配置的測試。 在大型項目中,有很多配置代碼。 因此通常在大型項目中使用。 **摘要:** 需要 XSLT 報告以非常用戶友好的方式增強 TestNG 報告功能。 * XSLT 代表可擴展樣式表語言轉換。 * ANT build 的下載和安裝參考給定的鏈接。 * 在 selenium 中生成 XSLT 報告,并從 eclipse 中執行 build.xml。 * 驗證來自項目文件夾的 XSLT 報告。 * 驗證每種結果狀態的 XSLT 報告。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看