我擴展了Selenium命名空間。但它仍然不能識別GetXpathCount()函數。有誰知道解決方案?謝謝!有誰知道爲什麼GetXpathCount()在C#中不起作用?
int count = Selenium.GetXpathCount("ctl00_ContentPlaceHolder1_TVNCategoryGridView");
我得到了以下錯誤消息:
類型或命名空間名稱GetXPathCount'不存在命名空間「硒」存在(?是否缺少程序集引用)
以下是整個代碼結構:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Selenium;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using System.Threading;
using NUnit.Framework;
.......(test class extending base test)
public void TestSetup()
{
Driver = CreateDriverInstance(BaseUrl);
Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
Driver.SwitchTo().Window(Driver.CurrentWindowHandle);
}
[TestCleanup()]
public void TestCleanup()
{
Driver.Quit();
}
[Priority(1), TestMethod]
public void NewShowTest()
{
Open("~/NewShow.aspx");
Random rnd = new Random(DateTime.Now.Second);
string shownum = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " " + rnd.Next(0, 10000).ToString();
testShowName = "Test Show " + shownum;
int count = Selenium.GetXpathCount("ctl00_ContentPlaceHolder1_TVNCategoryGridView");
..........
}
你正在使用哪個版本的硒?該xpath是否正確? xpath應該是// div的格式。請參閱以下鏈接:http://selenium.googlecode.com/git/docs/api/dotnet/html/M_Selenium_ISelenium_GetXpathCount.htm – Santoshsarma 2013-02-20 04:42:13
向我們展示您的整個代碼,包括您首先啓動Selenium的位置。你看起來像你正在使用RC或WebDriverBackedSelenium,但你已經用'webdriver'標記了這個問題......所以你在用什麼? – Arran 2013-02-20 09:34:25
我加了上面的代碼結構 – 2013-02-20 18:16:28