如何在C#中编写相同的代码?
List<WebElement> displayedOptions = driver.FindElements(By.TagName("select"));
for (WebElement option : displayedOptions)
{
if (option.displayed)
{
displayedOptions.Add(option);
}
}
Run Code Online (Sandbox Code Playgroud) 当我在NUnit中运行这个程序时,我收到一个错误
你调用的对象是空的.
虽然这不是原始程序,但我也遇到了类似的错误.任何帮助赞赏.异常发生在
driver.Navigate().GoToUrl("http://www.yahoo.com/");
Run Code Online (Sandbox Code Playgroud)
程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
namespace Class_and_object
{
[TestFixture]
public class Class1
{
IWebDriver driver = null;
[Test]
public void test1()
{
class2 obj = new class2();
driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com/");
obj.method();
}
}
public class class2
{
IWebDriver driver = null;
public void method()
{
driver.Navigate().GoToUrl("http://www.yahoo.com/");
}
}
}
Run Code Online (Sandbox Code Playgroud)