public void CanUseComponentAndStaticContentFromExternalNuGetPackage() { var appElement = MountTestComponent <ExternalContentPackage>(); // NuGet packages can use Blazor's JS interop features to provide // .NET code access to browser APIs var showPromptButton = appElement.FindElements(By.TagName("button")).First(); showPromptButton.Click(); var modal = new WebDriverWait(Browser, TimeSpan.FromSeconds(3)) .Until(SwitchToAlert); modal.SendKeys("Some value from test"); modal.Accept(); var promptResult = appElement.FindElement(By.TagName("strong")); WaitAssert.Equal("Some value from test", () => promptResult.Text); // NuGet packages can also embed entire Blazor components (themselves // authored as Razor files), including static content. The CSS value // here is in a .css file, so if it's correct we know that static content // file was loaded. var specialStyleDiv = appElement.FindElement(By.ClassName("special-style")); Assert.Equal("50px", specialStyleDiv.GetCssValue("padding")); // The external Blazor components are fully functional, not just static HTML var externalComponentButton = specialStyleDiv.FindElement(By.TagName("button")); Assert.Equal("Click me", externalComponentButton.Text); externalComponentButton.Click(); WaitAssert.Equal("It works", () => externalComponentButton.Text); }
public void CheckFormPage() { /**********************ARRANGE*********************/ /*Initializing the Iwebdriver*/ driver = new FirefoxDriver(); /*Implicit pageload timeout*/ driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(5); Boolean nextPageLoaded = true; /************************ACT************************/ /* Navigating to the homepage url*/ driver.Navigate().GoToUrl(formPageLoc); Thread.Sleep(2000); /* Click on Submit button without filling any of the field*/ driver.FindElement(By.XPath("//*[@id='myform']/input[8]")).Click(); /* Check if the alert box is present*/ IAlert alert = new WebDriverWait(driver, TimeSpan.FromTicks(10)).Until(ExpectedConditions.AlertIsPresent()); /* Accept the alert box if present*/ if (alert != null) { driver.SwitchTo().Alert(); alert.Accept(); } IWebElement label = driver.FindElement(By.XPath("//*[@id='myform']/label[1]")); string labelName = label.Text; /* After clicking on submit the page should remain the same. It should not * move to a different page. This is check by the labl used in the form*/ if (labelName.Contains("First Name")) { nextPageLoaded = false; } /***********************ASSERT*************************/ /* Check if the control remains on the same page using Assert*/ Assert.AreEqual(false, nextPageLoaded); Thread.Sleep(3000); driver.Close(); }