【发布时间】:2018-04-08 08:57:30
【问题描述】:
我有一个 Selenium 框架,它自创建以来一直一帆风顺。我今天实现了 Visual Studio Team Explorer,从我的远程分支拉出后,Intellisense 开始对我大喊大叫,说我的命名空间之一不存在。它不喜欢的线条是
using PageObjectModel.PageObjects.Maintenance;
和
var SettlementAccountReconciliations = new SettlementAccountReconciliation(_driver);
SettlementAccountReconciliation 位于维护目录中。这是我不喜欢目录的测试类的完整代码:
using NLog.Internal;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using PageObjectModel.ControlObjects;
using PageObjectModel.PageObjects;
using PageObjectModel.PageObjects.Process;
using PageObjectModel.PageObjects.Status;
using System;
using PageObjectModel.PageObjects.Maintenance; // **LINE WITH MAINTENANCE UNDERLINED**
namespace PageObjectModel.Tests.TaskTesting
{
[TestFixture]
class JiraTaskTesting
{
private IWebDriver _driver;
[OneTimeSetUp]
public void SetUp()
{
_driver = new ChromeDriver();
DriverContext.Driver = _driver;
_driver.Manage().Window.Maximize();
var ConfigManager = new ConfigurationManager();
var Login = new Login(_driver);
Login.SignIn(ConfigManager.AppSettings["Username"], ConfigManager.AppSettings["Password"]);
}
[Test]
public void ReportNameStandardizationSettlementAccountReconciliations()
{
// **LINE WITH UNDERLINE**
var SettlementAccountReconciliations = new SettlementAccountReconciliation(_driver);
var Utilities = new Utilities(_driver);
var ReportPopup = SettlementAccountReconciliations.ExportReconciliationReport();
ReportPopup.StartDate.SetValue(DateTime.Now.ToString("MM/dd/yyyy"));
ReportPopup.EndDate.SetValue(DateTime.Now.ToString("MM/dd/yyyy"));
ReportPopup.ExportButton.Click();
Assert.IsTrue(Utilities.ValidateFilePresent("Settlement Account Reconciliation"));
Utilities.DeleteFile("Settlement Account Reconciliation");
}
此外,这里是维护命名空间中的 SettlementAccountReconciliation:
using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;
using OpenQA.Selenium.Support.UI;
using System;
namespace PageObjectModel.PageObjects.Maintenance
{
public class SettlementAccountReconciliation
{
private readonly IWebDriver _driver;
public SettlementAccountReconciliation(IWebDriver driver)
{
_driver = driver;
PageFactory.InitElements(driver, this);
var Utilities = new Utilities(driver);
string TradingUrl = Utilities.RefactorUrl("/SettlementAccountReconciliation");
driver.Navigate().GoToUrl(TradingUrl);
WebDriverWait Wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
try
{
Wait.Until(ExpectedConditions.ElementExists(By.XPath("//a[text()='Settlement Account Reconciliations']")));
Console.WriteLine("SettlementAccountReconciliation Page Label Found");
}
catch
{
Console.WriteLine("SettlementAccountReconciliation Page Label Not Found, timing out");
}
}
对于 SettlementAccountReconciliation 构造函数:
我的所有代码都采用页面对象模型格式,这就是我的文件结构的排列方式:
我知道这个问题很啰嗦,但要继续,测试运行得很好,解决方案的构建就像一个魅力。我只需要弄清楚如何让文本编辑器不认为我的代码有问题。
Visual Studio 告诉我“命名空间 PageObjectModel.PageObjects 中不存在类型或命名空间名称 'Maintenance'”,但确实存在。
对此的任何帮助将不胜感激。
编辑:
我修好了。
我不知道为什么它有效,但它确实有效。
我所做的只是将维护文件夹重命名为维护1,重新创建维护文件夹,并将 SettlementAccountReconciliation 类拖放到维护文件夹中。
我猜有一些随机属性或设置存储在 Timbuktu 某处的临时文件夹中,该文件夹是为现有文件夹存储的,在创建新文件夹时被重置或删除。
感谢所有花时间帮助我的人!
【问题讨论】:
-
你使用resharper吗?还有,你用的是什么版本的VS2017?
-
检查是否在编译定义 PageObjectModel.PageObjects.Maintenance 命名空间的项目和文件时出现错误。
-
你试过恢复你的 nuget 包吗?
-
您是否再次打开和关闭了 Visual Studio? (重新启动,只是开个玩笑——有时编辑器搞砸了)
-
@JoshuaMiller - 我已经重启了 VS 和我的整台机器
标签: c# visual-studio visual-studio-2017 intellisense