• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 網站測試自動化系統—基于Selenium和VSTT(2)

    發表于:2012-09-10來源:不祥作者:知平軟件點擊數: 標簽:selenium
    // 變慢,所以 public const string TimeToWaitForPageLoad = 30000; } public class TestLibrary { public UserOperationsHelper UserHelper { get; private set; } } public class TestClass { [TestMethod]

      // 變慢,所以

      public const string TimeToWaitForPageLoad = "30000";

      }

      public class TestLibrary

      {

      public UserOperationsHelper UserHelper { get; private set; }

      }

      public class TestClass

      {

      [TestMethod]

      public void LogOnTest()

      {

      var username = "donjuan";

      var password = "它是個秘密";

      TestLibrary.UserHelper.LogOn(username, password);

      // 在測試過程中,我們發現這個鏈接是

      // 根據用戶名而變的,為了擴展性,動態生成其標識文本

      selenium.Click(string.Format("link={0}", username));

      selenium.WaitForPageToLoad(Consts.TimeToWaitForPageLoad);

      selenium.Click("link=博客");

      selenium.WaitForPageToLoad(Consts.TimeToWaitForPageLoad);

      // 執行一些必要的測試驗證過程

      Assert.IsTrue(selenium.IsTextPresented(...));

      }

      }

      這里稍微解釋一下,創建自動化測試代碼,就是為了節省手工重復測試的工作量以及測試失誤的風險。但只要是代碼,都會有可能出錯,因此自動化測試框架里面創建了一個CaseErrorException,這樣在每次分析測試用例失敗的時候,可以一眼區分開測試代碼的錯誤和產品代碼中的錯誤。例如在UserOperationHelper.LogOn函數中的參數檢查,當然啦,在測試過程當中,有可能需要測試不輸入用戶名或者密碼的情況下,驗證登錄界面是否正常工作的情況。因此在驗證參數的時候,特意為這種情況留下了String.Empty的入口,而對于null值,則基本上可以判斷是因為測試人員在編寫代碼上的失誤(具體原因會在數據驅動測試里面講到)。

      至于TestLibrary的初始化,完全可以放到每一個測試類型的TestInitializer里面,如下表所示:

    [TestClass]

    public class AddBlogTest

    {

        private TestContext testContextInstance;

        public TestContext TestContext

        {

            get

            {

                    return testContextInstance;

            }

            set

            {

                testContextInstance = value;

            }

        }

     

        private TestLibrary TestLibrary;

        private ISelenium selenium;

     

        [TestInitialize]

        public void SetupTest()

        {

            TestLibrary = TestLibrary.SetupTest(TestContext);

            selenium = TestLibrary.Selenium;

        }

     

        [TestCleanup]

        public void TeardownTest()

        {

            TestLibrary.Shutdown();

        }

    }

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>