문제

Quinit 테스트를 실행하는 페이지의 정적 HTML 테스트 하네스 인 브라우저 페이지를로드하고 싶습니다.

성공 / 실패에서 값을 얻고, 그 값으로 테스트하고 싶습니다.

mstest / msUnit을 사용하여 페이지를로드하고 요소를 심문 할 수 있습니까?

도움이 되었습니까?

해결책

If you don't mind starting actual browser, and you don't want to put dependency on SeleniumRC (which is required for C#), you can use WatiN. Below little example from WatiN.

[Test] 
public void SearchForWatiNOnGoogle()
{
  using (var browser = new IE("http://www.google.com"))
  {
    browser.TextField(Find.ByName("q")).TypeText("WatiN");
    browser.Button(Find.ByName("btnG")).Click();

    Assert.IsTrue(browser.ContainsText("WatiN"));
  }
}

Or if you don't want to start real browser on machine you can try Selenium, and HtmlUnit. With Selenium you start HtmlUnit, tell it to load given page, and you read what you need via xpath. For example this is example from Selenium documentation how to do something similar:

using OpenQA.Selenium;
using OpenQA.Selenium.Remote;

class Example
{
    static void Main(string[] args)
    {

        ICapabilities desiredCapabilities = DesiredCapabilities.HtmlUnit();
        IWebDriver driver = new RemoteWebDriver(desiredCapabilities);

        driver.Navigate().GoToUrl("http://google.ca/");

        IWebElement element = driver.FindElement(By.Name("q"));
        element.SendKeys("Cheese!");
        element.Submit();
        System.Console.WriteLine("Page title is: " + driver.Title);
        driver.Quit();
        System.Console.ReadLine();
    }
}  

BTW with selenium you can use real browser also.

On the other hand if this page with results is local file, you just read the file and filter data you need.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top