namespace WatinTestGround
{
class Element_ID
{
//Google Search
public const string GOOGLE_URL = "http://www.google.co.uk";
public const string SEARCH_TEXTBOX_ID = "q";
public const string SEARCH_BUTTON_ID = "btnG";
}
}
Update the 'GoogleSearch' method within the 'WorkingExamples' class to use the 'Element_ID' class as shown below:
public static void GoogleSearch()
{
//Line 1
IBrowser browser = BrowserFactory.Create(BrowserType.InternetExplorer);
//Line 2. Find the search text field and type Watin in it
browser.GoTo(Element_ID.GOOGLE_URL);
//Line 3
ITextField searchText = browser.TextField(Element_ID.SEARCH_TEXTBOX_ID);
//Line 4
searchText.Value = "Watin";
//Line 5
IButton searchButton = browser.Button(Element_ID.SEARCH_BUTTON_ID);
//Line 6
searchButton.Click();
//Line 7
browser.Dispose();
}
You'll notice line 2, 3 & 5 now reference the 'Element_ID' class to obtain the ID's\Names we used to hard code within our methods.
No comments:
Post a Comment