我如何在C#中使用Selenium? [英] How do I use Selenium in C#?
本文介绍了我如何在C#中使用Selenium?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
硒。
我下载了C#驱动器和IDE。我设法记录一些actiona并成功地从IDE运行它们,但现在我想,使用C#做的。我添加了所有相关的DLL(火狐)的项目,但我没有硒
类。一些世界你好就好了。
I downloaded the C# drivers and the IDE. I managed to record some actiona and successfully run them from the IDE, but now I want to do that using C#. I added all relevant DLLs (Firefox) to the project, but I don't have the Selenium
class. Some hello world would be nice.
推荐答案
从的硒文档:
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
class GoogleSuggest
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
//Notice navigation is slightly different than the Java version
//This is because 'get' is a keyword in C#
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Cheese");
System.Console.WriteLine("Page title is: " + driver.Title);
driver.Quit();
}
}
这篇关于我如何在C#中使用Selenium?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文