我扩展了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