2011-07-22 4 views
0

私はSelenium 2.0を使用しています。正しい正準リンクがテストされていることをテストしたいと思います。どうすればC#でwebdriverを使ってこれを得ることができますか?C#Selenium 2 Test Canonical Linke

ような何か:私が警告したい唯一のことは、ということです

// Assume driver is a correctly initialized IWebDriver instance, 
// pointed at the page in question 
IWebElement head = driver.FindElement(By.TagName, "head"); 

// Could also use By.XPath here with an appropriate XPath expression like 
// FindElement(By.XPath, "./link[@rel='canonical']") 
IWebElement link = head.FindElement(By.CssSelector, "link[@rel='canonical']"); 

:私はこれを具体的に試していないが、私はおそらく、このようにそれに近づくだろうWebDriver.FindElementByName("head").FindElement(By.Rel....

<head> 
    <link href="http://www.test.com/canonical" rel="canonical" /> 
    <link href="/Content/Reset.css" rel="stylesheet" type="text/css" /> 
    <link href="/Content/Site.css" rel="stylesheet" type="text/css" /> 
    ... 

答えて

0

その下の要素を見つけることは問題があるかもしれません。