如何在 C# 中使用 Selenium?

编程入门 行业动态 更新时间:2024-10-25 12:16:27
本文介绍了如何在 C# 中使用 Selenium?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

硒.

我下载了 C# 客户端驱动程序和 IDE.我设法记录了一些测试并成功地从 IDE 运行它们.但现在我想使用 C# 来做到这一点.我将所有相关的 DLL 文件 (Firefox) 添加到项目中,但我没有 Selenium 类.一些你好,世界!会很好.

I downloaded the C# client drivers and the IDE. I managed to record some tests and successfully ran them from the IDE. But now I want to do that using C#. I added all relevant DLL files (Firefox) to the project, but I don't have the Selenium class. Some Hello, World! would be nice.

推荐答案

来自 Selenium 文档:

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("www.google/"); IWebElement query = driver.FindElement(By.Name("q")); query.SendKeys("Cheese"); System.Console.WriteLine("Page title is: " + driver.Title); driver.Quit(); } }

更多推荐

如何在 C# 中使用 Selenium?

本文发布于:2023-11-03 06:41:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554477.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Selenium

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!