简体   繁体   English

使用Visual Studio 2010在Firefox中使用C#自动化网站/ Web表单?

[英]Automating Website/Web forms using C# in Firefox, using Visual Studio 2010?

If anyone can help me I'd appreciate it. 如果有人可以帮助我,我会很感激。

I'm working on a C# file in Visual Studio 2010 that I need to be able to test a website with multiple form pages, for the purpose of an example we'll refer to them all as 1.aspx, 2.aspx etc. 我正在使用Visual Studio 2010中的C#文件,我需要能够测试具有多个表单页面的网站,出于示例的目的,我们将它们全部称为1.aspx,2.aspx等。

I've my code that fills out the first page (1.aspx) fine, and click the "continue" button to load the next page, but when it gets to 2.aspx it won't continue to fill out the form. 我的代码填写了第一页(1.aspx),然后单击“继续”按钮加载下一页,但是当它到达2.aspx时它将不会继续填写表单。

We'll say an element on the 2.aspx page is called "DOB". 我们会说2.aspx页面上的一个元素叫做“DOB”。 On trying to run from the start (I've all the pages form data in the one .cs file) I get an error like "DOB does not exist in the current context". 在尝试从一开始运行时(我的所有页面都在一个.cs文件中形成数据)我得到一个错误,例如“DOB在当前上下文中不存在”。

Anyone's insight into this would be really appreciated! 任何人对此的见解都会非常感激!

In all honesty, it sounds like you might be better off using the WatiN Framework . 老实说 ,听起来你可能会更好地使用WatiN框架 I have been writing automation with it for years and the way that it is implemented and its ease-of-use make it worth the slight learning curve. 多年来我一直在编写自动化程序,它的实现方式和易用性使其值得学习。

Just to add a bit more to the answer; 只是为答案增加一点; and yes, this is pseudo-code: 是的,这是伪代码:

[Test]
public void Should_attach_to_browser()
{
     ExecuteTest(browser =>
     {
          browser.GoTo(NewWindowUri);
          browser.Link(Find.First()).Click();

          var findBy = Find.ByTitle("New window");
          var newWindow = Browswer.AttachTo(browser.GetType(), findBy);
          newWindow.Close();
     });          
}

In the code above, note the Browser.AttachTo(browser.GetType(), findBy); 在上面的代码中,请注意Browser.AttachTo(browser.GetType(), findBy); method. 方法。 Based on what I have understood of your question, the .AttachTo() method would work well since you would be able to take the focus off the current form and assign it to the next in your work/execution flow. 根据我对你的问题的理解, .AttachTo()方法可以很好地工作,因为你可以将焦点当前表单中.AttachTo()并将其分配给工作/执行流程中的下一个表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 身份验证如何应用于在Visual Studio 2010中使用C#的Web应用程序的所有aspx页面? - How does the authentication apply to all aspx pages for a Web Application using C# in Visual Studio 2010? 在visual studio professional 2010上使用试用版部署Web应用程序c# - Deploying a web application using the trial version on visual studio professional 2010 c# 如何在 Visual Studio 2019 中使用 Xamarin Forms(UWP) 和 C# 创建 Web 应用程序 - How to create Web application using Xamarin Forms(UWP) and C# in visual studio 2019 使用c#将Access数据库添加到Visual Studio 2010中的项目中 - Adding Access Database to Project in Visual Studio 2010 using c# 使用C#在Visual Studio 2010中使用预处理程序指令 - Using Preprocessor Directives in Visual Studio 2010 with C# 在Visual Studio 2010 C#中使用新的CultureInfo货币 - Using a new cultureinfo currency in Visual Studio 2010 C# 在C#中使用Visual Studio 2010进行批量插入 - Bulk insertion using Visual Studio 2010 in C# 在Visual Studio 2010中将压缩与C#Web服务客户端一起使用 - Using compression with C# webservice client in Visual Studio 2010 SOAP xml客户端 - 使用Visual Studio 2010 c# - 如何? - SOAP xml client - using Visual Studio 2010 c# - how? 使用 Visual Studio 2010 将 VB 项目代码更改为 C# - Change VB project code to C# using Visual Studio 2010
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM