[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 767
  • Last Modified:

Watin automated web testing in .net

Hi,

  I am trying to setup an automated web testing framework, using Watin, for my .net web application . To get started, I created an C# console application with the sample code they have given in the watin.org. Below is the C# code.

class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            GetGoogle();
        }

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

                bool test = browser.ContainsText("Watin");

                string test4 = "";
            }
        }
    }

Open in new window


When I ran this code, it opens the google.com in IE browser. However, it does not click the search button. I also tried with Find.ByValue("Google Search"), but it doesn't click the button.

What am I doing wrong here?

- Vishnu
0
kvishnusharma
Asked:
kvishnusharma
1 Solution
 
Kalpesh ChhatralaSoftware ConsultantCommented:
Hi,

"Google Search" Button Name is btnK

try like below.

browser.Button(Find.ByName("btnK")).Click();


hth
Kalpesh
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now