且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何自动点击按钮并从网站自动填写输入字段?

更新时间:2023-02-15 14:06:50

您可以使用其中一个网站测试库/工具,如 WatiN [ ^ ]

示例代码:



 [测试] 
public void SearchForWatiNOnGoogle()
{
使用 var browser = new IE( http://www.google.com))
{
browser.TextField(Find.ByName( q))。TypeText( WatiN);
browser.Button(Find.ByName( btnG))。点击();

Assert.IsTrue(browser.ContainsText( WatiN));
}
}



您可以在CP中找到许多相关文章 [ ^ ]


Hi everyone !
I want to fill the input field html and click on button "cotation" programmatically from this website: http://www.wine-searcher.com/wine-valuation-f.lml

please how can I do that in code behind C# using asp.net ?

You can use one of web site testing libraries/tools like WatiN[^]
sample code:

[Test]
public void SearchForWatiNOnGoogle()
{
  using (var browser = new IE("http://www.google.com"))
  {
    browser.TextField(Find.ByName("q")).TypeText("WatiN");
    browser.Button(Find.ByName("btnG")).Click();

    Assert.IsTrue(browser.ContainsText("WatiN"));
  }
}


You can Find many related articles in CP[^]