有没有办法转到 watin 页面中的所有链接我使用了以下代码但没有用
几天前,我使用相同的代码来访问每个页面,今天它不起作用。有谁知道除此之外的其他方法:
var browser = new IE("http//www.xyz.com");
foreach (Link l in browser.Links)
{
Console.WriteLine(l.Url);
if (l.Url.IndexOf("javascript") == -1)
{
browser.GoTo(l.Url);
browser.WaitForComplete();
Thread.Sleep(200);
browser = IE.AttachTo<IE>(Find.ByUrl(browser.Url));
browser.Back();
}
}
error Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
couple of days back i have used the same code to go to each and every page, today it doesn't work. Does anyone know an other approach than this:
var browser = new IE("http//www.xyz.com");
foreach (Link l in browser.Links)
{
Console.WriteLine(l.Url);
if (l.Url.IndexOf("javascript") == -1)
{
browser.GoTo(l.Url);
browser.WaitForComplete();
Thread.Sleep(200);
browser = IE.AttachTo<IE>(Find.ByUrl(browser.Url));
browser.Back();
}
}
error Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NullReferenceException
意味着您正在尝试调用空对象的方法或访问空对象的字段/属性。您需要单步执行此代码并找出不应使用调试器时的 null 值。A
NullReferenceException
means that you are trying to call a method or access a field/property of a null object. You need to step through this code and figure out what is null when it shouldn't be using the debugger.