public void ClickAnElement() { // Launch an instance of the browser Manager.LaunchNewBrowser(); // Some test cases may require that all cookies be cleared ahead of time. // WebAii does not care but depending on your environment and your specific // test case you may care. ActiveBrowser.ClearCache(ArtOfTest.WebAii.Core.BrowserCacheType.Cookies); // Navigate to the test page ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Find the elements on the page using the Find.BYxxx methods. Element toggleOn = Find.ById("btn1"); Element toggleOff = Find.ById("btn2"); // Now click the toggleOn button. Actions.Click(toggleOn); // Now click the toggleOff button. Actions.Click(toggleOff); // Now click the link Actions.Click(Find.ByTagIndex("a", 0)); Assert.IsTrue(ActiveBrowser.Url.Contains("google")); // DO ANY TEST VERIFICATION HERE }
public void TestWithWebAii() { int usersExpectedCount = 1; int coursesExpectedCount = 0; int tracksExpectedCount = 0; string coursesName = "Курсове"; string tracksName = "Тракове"; string usersName = "Потребители"; string text = "WebAii "; ActiveBrowser.NavigateTo("http://telerikacademy.com/"); SearchForText(text); var coursesCount = GetResultSubareaCount(coursesName); Assert.AreEqual(coursesExpectedCount, coursesCount, "Wrong courses count."); var tracksCount = GetResultSubareaCount(tracksName); Assert.AreEqual(tracksExpectedCount, tracksCount, "Wrong track count."); var usersCount = GetResultSubareaCount(usersName); Assert.AreEqual(usersExpectedCount, usersCount, "Wrong users count."); }
public void PureDesktopUIActions() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); Desktop.Mouse.HoverOver(this.Elements.GetHtml("Cell00").GetRectangle()); Desktop.Mouse.HoverOver(this.Elements.GetHtml("Cell01").GetRectangle()); Desktop.Mouse.HoverOver(this.Elements.GetHtml("Cell10").GetRectangle()); Desktop.Mouse.HoverOver(this.Elements.GetHtml("Cell11").GetRectangle()); // Now click inside the textbox. Desktop.Mouse.Click(MouseClickType.LeftClick, this.Elements.GetHtml("TextBox").GetRectangle()); // Type some text Desktop.KeyBoard.TypeText("'Hello from Telerik Testing Framework'", 5); Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab); // this to invoke the onchange event ActiveBrowser.WaitUntilReady(); ActiveBrowser.RefreshDomTree(); // Given that the DOM has changed. You can either Re-Find all elements // by forcing a call to Find.All() or simply refreshing the element you need: this.Elements.GetHtml("MessageLabel").Refresh(); Assert.IsTrue(this.Elements.GetHtml("MessageLabel").InnerText.Contains("Telerik Testing Framework")); }
public void VisuallyCapturingBrowserStates() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Capture the browser state visually as a bitmap. // This will capture the bitmap as a bmp file and store it in the // log location with a link pointing to it added to the log. // The bitmap is also accessible using Log.CapturedBitmaps collections Log.CaptureBrowser(ActiveBrowser); // // OR // // Capture the bitmap to an in memory bitmap. // Note: // // The GetBitmap() method should work with any Window object regardless // whether it is the browser window or any other Window object. Bitmap myBrowser = ActiveBrowser.Window.GetBitmap(); Assert.IsTrue(myBrowser.Size == myBrowser.Size); }
public void AccessingTestRegions() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // The TestPage has 5 TestRegions defined on it. They all can be accessed // using the DomTree.Regions collection which contains a flat list of // all regions regardless of their nesting in the markup. Assert.IsTrue(ActiveBrowser.Regions.Count == 5); // Access the MainTable test region. TestRegion mainTable = ActiveBrowser.Regions["MainTable"]; Assert.IsTrue(mainTable.Id.Equals("MainTable")); // Access the programs table header. TestRegion programsTableHeader = ActiveBrowser.Regions["ProgramsTableHead"]; // Or - You can walk down the hierarchy of test regions. // // Note: The only reason you might want to do that is to validate a certain // high-level structure of your page as part of your testing // to make sure that all main parts are correctly positioned programsTableHeader = mainTable.ChildRegions["ProgramsTable"].ChildRegions["ProgramsTableHead"]; // TestRegion.ChildRegions contains only the immediate child // TestRegions where AllChildRegions contains all sub TestRegions // regardless of their nesting even within other sub TestRegions. Assert.IsTrue(mainTable.ChildRegions.Count == 1); Assert.IsTrue(mainTable.AllChildRegions.Count == 4); }
public void AccessHTMLPopups() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Set new browser tracking to enabled. // This will make all new browser instances connect to // the Manager. Manager.SetNewBrowserTracking(true); // Invoke the popup Actions.Click(this.Elements.GetHtml("mylink")); // Wait for the new browser instance to connect. Manager.WaitForNewBrowserConnect("www.bing.com", true, 3000); // disable new browser tracking Manager.SetNewBrowserTracking(false); // At this point the browsers collection should have two // browser instances. ActiveBrowser should be set // to the popup instance. Assert.AreEqual(2, Manager.Browsers.Count); Assert.IsTrue(ActiveBrowser.Url.Contains("www.bing.com")); // Close the popup ActiveBrowser.Close(); // At this point, the browsers collection should contain // only one instance and the ActiveBrowser is set to // the last launched active instance. Assert.AreEqual(1, Manager.Browsers.Count); Assert.IsTrue(ActiveBrowser.Url.Contains(Path.GetFileName(TESTPAGE))); }
public void ExtensibleWebAiiEvents() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // // Events setup // // Logging events: Triggered each time a Log.WriteLine is fired. Log.LogWrite += new EventHandler <ArtOfTest.WebAii.EventsArgs.LogWriteEventArgs>(Log_LogWrite); // Browser events: BeforeCommandExecuted/AfterCommandExecuted/DOMRefreshed ActiveBrowser.BeforeCommandExecuted += new EventHandler <ArtOfTest.WebAii.EventsArgs.BrowserCommandEventArgs>(ActiveBrowser_BeforeCommandExecuted); ActiveBrowser.AfterCommandExecuted += new EventHandler <ArtOfTest.WebAii.EventsArgs.BrowserCommandEventArgs>(ActiveBrowser_AfterCommandExecuted); ActiveBrowser.DomRefreshed += new EventHandler(ActiveBrowser_DomRefreshed); // Find events: When a failed search returns null or an empty list for Find.Allxx Find.ReturnedNullOrEmpty += new EventHandler <ArtOfTest.WebAii.EventsArgs.ReturnedNullOrEmptyEventArgs>(Find_ReturnedNullOrEmpty); // Perform a command to simulate the browser events ActiveBrowser.Refresh(); // Perform a find operation to simulate the find events Element e = Find.ById("invalidId"); // Perform a log operation to simulate the logging events Log.WriteLine("Logging from Test"); }
public void TestSumCalculation() { string expectedResult = "3"; ActiveBrowser.NavigateTo(BaseUrl); var calculator = Find.ById <HtmlTable>("calc"); var display = calculator.Find.ById <HtmlInputText>("calc_result"); var one = GetButtonByValue(calculator, "1"); one.Click(); Assert.AreEqual("1", display.Value); var plus = GetButtonByValue(calculator, "+"); plus.Click(); var two = GetButtonByValue(calculator, "2"); two.Click(); Assert.AreEqual("2", display.Value); var equals = GetButtonByValue(calculator, "="); equals.Click(); Assert.AreEqual(expectedResult, display.Value); }
public void IEModalDialogsSupport() { Manager.LaunchNewBrowser(BrowserType.InternetExplorer, true); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE2)); // Open the popup using mouse click so it doesn't hang execution. Find.ByAttributes <HtmlInputButton>("type=button").MouseClick(); // ** Special IE Code. Given that IE Dialog is an IE specific feature. if (ActiveBrowser.BrowserType == BrowserType.InternetExplorer) { InternetExplorerActions ieActions = (InternetExplorerActions)ActiveBrowser.Actions; // Connect the dialog ieActions.ConnectIEDialog("THIS IS A MODAL DIALOG", 300); Manager.WaitForNewBrowserConnect("dialog.html", true, 10000); Assert.IsTrue(ActiveBrowser.IsIEDialog); // The ActiveBrowser instance is now the dialog instance. Do what ever you want with the dialog ActiveBrowser.Find.ByTagIndex <HtmlContainerControl>("H1", 0).BaseElement.SetValue <string>("style.backgroundColor", "red"); // Once done, make sure to close the dialog. // Even if the dialog is closed due to a button click within the dialog, you still need this line // at this point to revert the ActiveBrowser instance to the main instance. We are searching for a // good approach to make this automatic. ActiveBrowser.Close(); } Assert.IsFalse(ActiveBrowser.IsIEDialog); // The ActiveBrowser is back to the main browser window. ActiveBrowser.NavigateTo("http://www.google.com"); }
public void EnableAnnotation() { // Launch an instance of the browser Manager.LaunchNewBrowser(); // Navigate to the test page ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // [You can set these globally in the config file too] // Enable Annotated Execution. Manager.Settings.AnnotateExecution = true; // Slow down test execution so we can visually track the actions on the page. Manager.Settings.ExecutionDelay = 500; // half a second wait between actions. // Perform the actions DoSomeAction(Actions); // Customize the Annotation Visually and perform the actions again. ActiveBrowser.Annotator.Settings.BackColor = Color.Gray; ActiveBrowser.Annotator.Settings.FontemSize = 15; ActiveBrowser.Annotator.Settings.BackColorAlpha = 200; ActiveBrowser.Annotator.Settings.Color = Color.HotPink; ActiveBrowser.Annotator.Settings.FontStyle = FontStyle.Italic; ActiveBrowser.Annotator.Settings.BorderWidth = 3; DoSomeAction(Actions); // Disable Annotated Execution. Manager.Settings.AnnotateExecution = false; DoSomeAction(Actions); }
public void VerifyDialogText_CodedStep() { ActiveBrowser.NavigateTo("http://www.w3schools.com/JS/tryit.asp?filename=tryjs_alert"); // Click the button to fire the Alert Dialog inside the browser FrameInfo myFrame = new FrameInfo("iframeResult", "", "", 0); Browser frame = ActiveBrowser.Frames[myFrame]; HtmlButton tryItButton = frame.Find.ByTagIndex <HtmlButton>("button", 0); //Console.WriteLine(tryItButton); Assert.IsNotNull(tryItButton); // Initialize custom 'Alert' dialog handler AlertDialog alertDialog = AlertDialog.CreateAlertDialog(ActiveBrowser, DialogButton.OK); Manager.DialogMonitor.Start(); alertDialog.HandlerDelegate = MyCustomAlertHandler; Manager.DialogMonitor.AddDialog(alertDialog); tryItButton.Click(); // Wait Until Dialog is Handled. alertDialog.WaitUntilHandled(20000); // Validate the text that was captured by the custom dialog handler Assert.AreEqual <string>("I am an alert box!", dialogText); }
public void FindElementsByID() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Set the short-cuts to the main automation objects. Browser brwser = Manager.ActiveBrowser; Find rootFind = brwser.Find; // All the testregion are initialized here. TestRegion r1 = brwser.Regions["Region1"]; TestRegion r11 = brwser.Regions["Region11"]; TestRegion r111 = brwser.Regions["Region111"]; TestRegion r1111 = brwser.Regions["Region1111"]; TestRegion r112 = brwser.Regions["Region112"]; //*** Using identification by id. Element div0 = r1.Find.ById("div0"); //*** Using tag name occurrence index. Element div = r1.Find.ByTagIndex("div", 0); Element div1 = r112.Find.ByTagIndex("div", 0); // Some verification to illustrate how the same element that was found // using TestRegion Find objects above, can be also found // using the main Browser Find object. Assert.IsTrue(div.Equals(rootFind.ByTagIndex("div", 0))); Assert.IsTrue(div0.Equals(rootFind.ByTagIndex("div", 1))); //*** Using attribute identification. Assert.IsTrue(div1.Equals(rootFind.ByAttributes("id=div1"))); Assert.IsNull(rootFind.ByAttributes("id=bla")); Assert.IsNotNull(rootFind.ByAttributes("href=http://www.kayak.com")); //*** Using partial attribute identification. Assert.IsTrue(rootFind.ByAttributes("bla=~__").Equals(rootFind.ById("div7"))); Assert.IsNull(rootFind.ByAttributes("id=~div7", "bla=~wow")); Assert.IsNotNull(rootFind.ByAttributes("onclick=~clicked();", "id=~button2")); //*** Using 'All' elements identification. // Note here that the first 'div' does not have any id that contains 'div' hence the '- 1'. Assert.AreEqual(rootFind.AllByTagName("div").Count - 1, rootFind.AllByXPath("/descendant::node()[starts-with(@id,'div')]").Count); Assert.AreEqual(5, rootFind.AllByAttributes("href=http://www.kayak.com").Count); Assert.AreEqual(2, rootFind.AllByAttributes("id=~button").Count); Assert.AreEqual(10, r1.Find.AllByTagName("div").Count); Assert.AreEqual(0, r1111.Find.AllByTagName("div").Count); Assert.AreEqual(2, r111.Find.AllByTagName("a").Count); Assert.AreEqual(9, r11.Find.AllByAttributes("id=~div").Count); //*** Using NodeIndexPath identification. Assert.IsTrue(r1.Find.ByNodeIndexPath("0/1/1").IdAttributeValue.Equals("input1")); Assert.IsTrue(rootFind.ByNodeIndexPath("1/0/0").TagName.Equals("div", StringComparison.OrdinalIgnoreCase)); //*** Using name Assert.IsNull(r1.Find.ByName("bla")); }
public void WebExtTest1() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Set the text of the textbox Actions.SetText(this.Elements.GetHtml("InputTxtbx"), "test1"); }
public void GoToSPlan() { String bbaseUrl = Settings.Current.Web.BaseUrl.ToString(); String address = ("/Plan/?pt=PlanIEP"); Console.Out.WriteLine(address); ActiveBrowser.NavigateTo(Settings.Current.Web.BaseUrl + address, true); }
public void LogonDialogWithAttributes() { // TODO: Remove this line once you have updated this test with Url, UserName and Password throw new NotImplementedException( "LogonDialog() test method needs to be updated with a Url/UserName & Password before you can execute it!"); // Navigate to a page that needs a logon ActiveBrowser.NavigateTo("<Place a Url to LogOn to here>"); }
public void Register_CodedStep() { // Navigate to : 'http://automationpractice.com' ActiveBrowser.NavigateTo("http://automationpractice.com"); ActiveBrowser.Window.SetFocus(); Pages.MyStore.LogInToLink.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementTopAtWindowTop); Pages.MyStore.LogInToLink.MouseClick(); //ActiveBrowser.WaitForUrl("http://automationpractice.com",true,50000); }
public void MyTestInitialize() { #region WebAii Initialization // Initializes WebAii manager to be used by the test case. // If a WebAii configuration section exists, settings will be // loaded from it. Otherwise, will create a default settings // object with system defaults. // // Note: We are passing in a delegate to the VisualStudio // testContext.WriteLine() method in addition to the Visual Studio // TestLogs directory as our log location. This way any logging // done from WebAii (i.e. Manager.Log.WriteLine()) is // automatically logged to the VisualStudio test log and // the WebAii log file is placed in the same location as VS logs. // // If you do not care about unifying the log, then you can simply // initialize the test by calling Initialize() with no parameters; // that will cause the log location to be picked up from the config // file if it exists or will use the default system settings (C:\WebAiiLog\) // You can also use Initialize(LogLocation) to set a specific log // location for this test. Initialize(this.TestContext.TestLogsDir, new TestContextWriteLine(this.TestContext.WriteLine)); // If you need to override any other settings coming from the // config section you can comment the 'Initialize' line above and instead // use the following: /* * * // This will get a new Settings object. If a configuration * // section exists, then settings from that section will be * // loaded * * Settings settings = GetSettings(); * * // Override the settings you want. For example: * settings.DefaultBrowser = BrowserType.FireFox; * * // Now call Initialize again with your updated settings object * Initialize(settings, new TestContextWriteLine(this.TestContext.WriteLine)); * */ // Set the current test method. This is needed for WebAii to discover // its custom TestAttributes set on methods and classes. // This method should always exist in [TestInitialize()] method. SetTestMethod(this, (string)TestContext.Properties["TestName"]); #endregion Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle; Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); }
public void ChainedIdentificationTest() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Get the inner table. Element innerTable = Find.ByExpression("id=table1", "|", "tagindex=table:1"); Assert.IsNotNull(innerTable); Assert.AreEqual(3, innerTable.Children[0].Children.Count); }
public void JavascriptReturnsObject() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, "WebAii2Pages/JavascriptFunctions.html")); MyObject o = Actions.InvokeScript <MyObject>("getKeyValuePair();"); Assert.IsNotNull(o); Assert.AreEqual(1, o.One); Assert.AreEqual(15, o.Fifteen); }
public void FindElementByExpression() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // The find object will only return an element if all conditions // exist. Else NULL. Element e = Find.ByExpression(new HtmlFindExpression("TagIndex=div:1", "class=myclass")); Assert.IsNotNull(e); }
public void WebExtTest3() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Set the text of the textbox Actions.SetText(this.Elements.GetHtml("InputTxtbx"), "test2"); // NOTE: // "CheckBx" is not accessible from the this.Elements[] collection // here. Calling this.Elements["CheckBx"], will throw an exception. }
public void AccessingElementsUsingTestRegions() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Each TestRegion object has a Find object associated with it that // performs the search within the elements contained in that region ONLY. // Any element search that requires indexing will be performed with // the <testregion> tag of that region as the root element to start // the indexing from. Below are examples to illustrate that. // MainTable region contains the table id="maintable1" but other // regions don't contain it. TestRegion MainTableRegion = ActiveBrowser.Regions["MainTable"]; TestRegion ProgramsTableRegion = ActiveBrowser.Regions["ProgramsTable"]; // // Scoping Search To TestRegion: // Assert.IsNotNull(MainTableRegion.Find.ById("maintable1")); Assert.IsNull(ProgramsTableRegion.Find.ById("maintable1")); // // Scoping Indexing To TestRegion : // // Let's find the ProgramsTable using tag index. // // // A) Common search without TestRegions // [We usually index the tag name from the root of the page which in this // case is '1' - the second occurrence of the tag 'table'] Element secondTableWithoutTR = Find.ByTagIndex("table", 1); // B) Using TestRegions // [We only need to index from the beginning of the TestRegion we are accessing] Element secondTableWithTR = ProgramsTableRegion.Find.ByTagIndex("table", 0); Assert.IsTrue(secondTableWithoutTR.Equals(secondTableWithTR)); // Note: // // With B) we don't care how the page changes outside the testregion // this test is targetting. This means that we can literally take // that TestRegion and paste it in another page and the test should // work. In contrast with A) the test is more vulnerable to changes. For // example, if another table is added before ProgramsTable, the test // will break where B won't. // // For highly dynamic sites or sites in early development with // lots of churn, it is recommended to use TestRegions to limit // the cost of maintaining tests. }
public void LogonDialogTest() { // TODO: Remove this line once you have updated this test with Url, UserName and Password throw new NotImplementedException( "LogonDialog() test method needs to be updated with a Url/UserName & Password before you can execute it!"); // Add a logon dialog support with username/password Manager.DialogMonitor.AddDialog(LogonDialog.CreateLogonDialog(ActiveBrowser, "<username>", "<password>", DialogButton.OK)); Manager.DialogMonitor.Start(); // Navigate to a page that need a logon ActiveBrowser.NavigateTo("<Place a Url to LogOn to here>"); }
public void UseAspNetDevServer() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(TESTPAGE); Assert.IsTrue(ActiveBrowser.ViewSourceString.Contains("This is a test!")); // Note: // // We only need to include the page name here since we already set // the location as part of the Manager settings initialization. // // If you need to switch between AspNet Dev Server and IIS, you might // want to initialize a BaseUri that you append when running under IIS. }
public void TestClearFunction() { string expectedResult = "0"; ActiveBrowser.NavigateTo(BaseUrl); var calculator = Find.ById <HtmlTable>("calc"); var display = calculator.Find.ById <HtmlInputText>("calc_result"); ClickAndVerify(calculator, display, "9", "9"); ClickAndVerify(calculator, display, "0", "90"); ClickAndVerify(calculator, display, "CE", expectedResult); }
public void SimpleWin32UI() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); Element input1 = Find.ById("TextBox"); /// First scroll the element into view /// Then click on it to set the input focus to the input /// Simulate typing on the keyboard which should enter text /// into our control ActiveBrowser.Actions.ScrollToVisible(input1); Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, input1.GetRectangle()); Manager.Desktop.KeyBoard.TypeText("Hello there", 100); }
public void SearchResults() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo("http://telerikacademy.com/"); string wpfResult = ReturnSearchCategoriesCounts("WPF"); string qualityResult = ReturnSearchCategoriesCounts("Quality"); string webaiiResult = ReturnSearchCategoriesCounts("Webaii"); // The method returns string in the format count of [users],[courses],[tracks] Assert.AreEqual("0,2,1", wpfResult); Assert.AreEqual("1,5,1", qualityResult); Assert.AreEqual("1,0,0", webaiiResult); }
public void SetTextForAnElement() { // Launch an instance of the browser Manager.LaunchNewBrowser(); // Navigate to the test page ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Now set the text for the text box Actions.SetText(this.Elements.GetHtml("MyTextBox"), "This is a TEST for TextBox!"); // Now set the text for the text area. Actions.SetText(this.Elements.GetHtml("MyTextArea"), "This is a TEST for TextArea!"); // DO ANY TEST VERIFICATION HERE }
public void ImageDetection() { //we have to set following property before initialize method Manager.Settings.Web.UseHttpProxy = true; Manager.LaunchNewBrowser(BrowserType.InternetExplorer); ResponseListenerInfo li = new ResponseListenerInfo(CheckTypeForImage); Manager.Http.AddBeforeResponseListener(li); ActiveBrowser.NavigateTo("http://news.google.com/"); Manager.Http.RemoveBeforeResponseListener(li); // Check the test results for a log of all responses during the page load }
public void JavascriptReturnsJson() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, "WebAii2Pages/JavascriptFunctions.html")); // JsonObject offers access to weakly-typed Javascript objects JsonObject json = Actions.InvokeScript <JsonObject>("getKeyValuePair();"); // returns {one: 1, fifteen: 15} Assert.IsNotNull(json); Assert.IsNotNull(json["root"]); // All fields of the JSON object are accessed through the "root" key Assert.IsNotNull(json["root"]["one"]); Assert.AreEqual(1, (int)json["root"]["one"]); Assert.IsNotNull(json["root"]["fifteen"]); Assert.AreEqual(15, (int)json["root"]["fifteen"]); }