Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualStudio.TestTools.UITesting;
- using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
- namespace CodedUITestProject1 {
- public class CalculatorPageHtml {
- private BrowserWindow _simpleCalculator { get; set; }
- private string _browserPath = @"http://www.calculator.org/jcalc98.aspx";
- private HtmlDocument _htmlDocument { get; set; }
- private HtmlControl _htmlControl { get;set;}
- private HtmlCustom _htmlCustom {get;set;}
- private HtmlAreaHyperlink _htmlAreaHyperlink { get; set; }
- private HtmlEdit _htmlEdit { get; set; }
- public CalculatorPageHtml() {
- _simpleCalculator = BrowserWindow.Launch(_browserPath);
- _simpleCalculator.SearchProperties[UITestControl.PropertyNames.Name] = "Virtual Calc98";
- _simpleCalculator.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
- _htmlDocument = new HtmlDocument(_simpleCalculator);
- _htmlDocument.FilterProperties[HtmlDocument.PropertyNames.AbsolutePath] = "/jcalc98.aspx";
- _htmlCustom = new HtmlCustom(_htmlDocument);
- _htmlCustom.SearchProperties["TagName"] = "MAP";
- _htmlCustom.SearchProperties[UITestControl.PropertyNames.Name] = "mainkeypad";
- _htmlCustom.FilterProperties["ControlDefinition"] = "name=\"mainkeypad\"";
- _htmlCustom.FilterProperties["TagInstance"] = "2";
- _htmlAreaHyperlink = new HtmlAreaHyperlink(_htmlCustom);
- }
- public void SetNumberBox(int numberForTextBox) {
- string digits = numberForTextBox.ToString();
- foreach (var digit in digits) {
- var mb = string.Format("mb({0})", digit);
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.AbsolutePath] = mb;
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Href] = "javascript:" + mb;
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.TagInstance] = "7";
- Mouse.Click(_htmlAreaHyperlink);
- }
- }
- public void ClickAdd() {
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.AbsolutePath] = "Ib(\'+\')";
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Href] = "javascript:Ib(\'+\')";
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.TagInstance] = "14";
- Mouse.Click(_htmlAreaHyperlink);
- }
- public void ClickEqual() {
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.AbsolutePath] = "Nb()";
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Href] = "javascript:Nb()";
- _htmlAreaHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.TagInstance] = "19";
- Mouse.Click(_htmlAreaHyperlink);
- }
- public string VerifyAnswer() {
- _htmlEdit = new HtmlEdit(_htmlDocument);
- _htmlEdit.SearchProperties[HtmlEdit.PropertyNames.Name] = "display";
- _htmlEdit.SearchProperties[HtmlEdit.PropertyNames.Type] = "SINGLELINE";
- _htmlEdit.FilterProperties[HtmlEdit.PropertyNames.TagInstance] = "1";
- return _htmlEdit.Text;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement