加载网页并使用c#单击一个按钮 [英] load a web page and click a button using c#

查看:409
本文介绍了加载网页并使用c#单击一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要自动执行网页上的过程。

I have a requirement to automate a procedure on a web page.


  1. 打开网页

  2. 查找输入内容

  3. 单击它

  4. 关闭网页

  1. Open a web page
  2. Find an input
  3. Click on it
  4. Close the web page

我想实现所有以上在控制台应用程序中使用 c#。我不想打开任何浏览器,而只需要一个代码即可自动执行此过程。

I would like to achieve all of the above using c# in a console application. I dont want to open any browser, but just a code to automate this process.

我在网页上有 URL ,还具有 ID 输入元素。

I have a URL to a web page and also ID of an input element.

我应该使用什么c#代码来实现这一目标??

What c# code should I use to achieve this.?

推荐答案

我认为这可能可以达到目的。

I think this probably would be able to serve the purpose.

硒1(Selenium RC): Selenium Server, 启动并杀死浏览器,解释并运行从测试程序传递来的Selenese命令 ,并充当HTTP代理,拦截和验证在浏览器之间传递的HTTP消息

Selenium 1 (Selenium RC): The Selenium Server which launches and kills browsers, interprets and runs the Selenese commands passed from the test program, and acts as an HTTP proxy, intercepting and verifying HTTP messages passed between the browser and the AUT.

Selenium Server从您的测试程序中接收Selenium命令,对其进行解释,并将运行这些测试的结果报告给您的程序。

Selenium Server receives Selenium commands from your test program, interprets them, and reports back to your program the results of running those tests.

RC服务器将Selenium Core捆绑并自动将其注入浏览器。当您的测试程序打开浏览器(使用客户端库API函数)时,会发生这种情况。 Selenium-Core是一个JavaScript程序,实际上是一组JavaScript函数,这些函数使用浏览器的内置JavaScript解释器解释和执行Selenese命令。

The RC server bundles Selenium Core and automatically injects it into the browser. This occurs when your test program opens the browser (using a client library API function). Selenium-Core is a JavaScript program, actually a set of JavaScript functions which interprets and executes Selenese commands using the browser’s built-in JavaScript interpreter.

服务器接收到Selenese命令使用简单的HTTP GET / POST请求从您的测试程序中获取。这意味着您可以使用可以发送HTTP请求的任何编程语言来在浏览器上自动执行Selenium测试。

The Server receives the Selenese commands from your test program using simple HTTP GET/POST requests. This means you can use any programming language that can send HTTP requests to automate Selenium tests on the browser.

更多信息:您可以访问

For More: You can visit Selenium

这篇关于加载网页并使用c#单击一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆