我正在按照指南将 Visual Studio 中的输出数据写入谷歌电子表格。我将 NUnit 项目类型用于测试自动化目的。
在指南的最后有一个代码块,我粘贴在我的项目中:
using OpenQA.Selenium.Support.UI;
using System;
using NUnit.Framework;
using OpenQA.Selenium;
using System.Collections;
using System.Collections.Generic;
using Google.Apis.Sheets.v4;
using Google.Apis.Auth.OAuth2;
using System.IO;
using Google.Apis.Services;
using Newtonsoft.Json;
using WikipediaTests.Foundation_Class;
namespace AutomationProjects
{
[TestFixture]
public class TestClass : TestFoundation
{
public class SpreadSheetConnector
{
//Codeblock from guide pasted here!
}
[Test]
public void test1()
{
//Test case 1. Do XYZ...
}
}
}
在指南中包含的代码块中,有一段读取 JSON 凭证文件:
private void ConnectToGoogle()
{
GoogleCredential credential;
using (var stream = new FileStream(Path.Combine(HttpRuntime.BinDirectory, "Export Project-03e8aa07234e.json"),
FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream).CreateScoped(_scopes);
}
//...
但我得到一个错误的“HttpRuntime”说:Error CS0103 The name 'HttpRuntime' does not exist in the current context
VS 没有建议添加新的“使用”引用,所以我假设这不是问题。
那么可能是什么问题呢?从以下到整个代码块:指南