c# - 对象引用未设置为对象的实例(基础结构)
问题描述
我的硒测试有问题,这是错误,这意味着我不知道,可能有人可以帮助我解决代码结构吗?
正如我认为语句的结构是正确的,但为什么它在那里是错误的?
System.NullReferenceException: 'Object reference not set to an instance of an object.'
那是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using System.IO;
namespace DVSTesti.Common
{
public class CustomRemoteWebDriver : RemoteWebDriver
{
public static bool useExistingSession = false;
public static string sessiodIdPath = String.Format(@"{0}\..\..\sessionID.txt", AppDomain.CurrentDomain.BaseDirectory);
public CustomRemoteWebDriver(Uri remoteAddress, DesiredCapabilities dd) : base(remoteAddress, dd)
{
}
protected override Response Execute(string driverCommandToExecute, System.Collections.Generic.Dictionary<string,object> parameters)
{
if (driverCommandToExecute == DriverCommand.NewSession)
return ProcessNewSessionAction(parameters);
else
return base.Execute(driverCommandToExecute, parameters);
}
private Response ProcessNewSessionAction(Dictionary<string, object> parameters)
{
useExistingSession = false;
if (useExistingSession)
{
var sidText = File.ReadAllText(sessiodIdPath);
return new Response
{
SessionId = sidText,
};
}
else
{
var response = base.Execute(DriverCommand.NewSession, parameters);
File.WriteAllText(sessiodIdPath, response.SessionId);
return response;
}
}
}
}
谢谢!
解决方案
推荐阅读
- python - GeoPoint 类型的对象不是 JSON 可序列化的
- python - AttributeError:类型对象“类”没有属性“方法”
- android - Android DataBinding L***/****/common/BR 类中没有类型 I 的现场设备
- javascript - Firebase + Cordova:signInWithRedirect() 在 iOS 上返回 null 但在 Android 上进行身份验证
- mysql - 从 CSV 导入 SQL Server 时如何将日期列的文本数据类型转换为时间戳格式
- character-encoding - Base64 解码导致部分解码后跟不可打印字符
- r - 如何更改条形图 y 轴以表示它们的值?
- c - GCC 的 MSVC __asm 关键字是什么?
- view - Redshift View 不断恢复到以前的定义
- sparql - 泛化具有交叉限制的模式?