-
Notifications
You must be signed in to change notification settings - Fork 128
Angular support
pawelstryczek edited this page Sep 15, 2017
·
10 revisions
Following functionalities were implemented for AngularJS support.
public static void WaitForAngular(this IWebDriver webDriver, double timeout)
{
try
{
new WebDriverWait(webDriver, TimeSpan.FromSeconds(timeout)).Until(
driver =>
{
var javaScriptExecutor = driver as IJavaScriptExecutor;
return javaScriptExecutor != null
&&
(bool)javaScriptExecutor.ExecuteScript(
"return window.angular != undefined && window.angular.element(document.body).injector().get('$http').pendingRequests.length == 0");
});
}
catch (InvalidOperationException)
{
Logger.Info("Wait for angular invalid operation exception.");
}
}
Synchronization is added in GetElement function. If feature is enabled framework will wait for Angular process to be finished.
public static IWebElement GetElement(this ISearchContext element, ElementLocator locator, double timeout, Func<IWebElement, bool> condition, [Optional] string customMessage)
{
var driver = element.ToDriver();
if (DriversCustomSettings.IsDriverSynchronizationWithAngular(driver))
{
driver.WaitForAngular();
}
var by = locator.ToBy();
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout)) { Message = customMessage };
wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException));
wait.Until(
drv =>
{
var ele = element.FindElement(@by);
return condition(ele);
});
return element.FindElement(@by);
}
To enable feature this.Driver.SynchronizeWithAngular(true); need to be added. To disable this.Driver.SynchronizeWithAngular(false);
Please notice that sychronization will not work when default FindElement is using instead of GetElement from the framework.
- Home
- Getting started
- Parallel tests execution
- MsTest DataDriven tests from Xml and CSV files
- NUnit DataDriven tests from Xml, CSV and Excel files
- Comparing files by NUnit DataDriven tests
- Visual Testing
- Screen shots: full desktop, selenium. PageSource saving
- Verify-asserts without stop tests
- Downloading files
- Helpers
- Override browser profile preferences, install browser extensions, Headless mode
- Debugging Test.Automation framework
- Logging
- Performance measures
- Webdriver Extends
- More common locators
- Selenium-Grid-support
- Advanced Browser Capabilities and Options
- AngularJS synchronization
- Update App.config or appsettings.json
- Cross browser parallel test execution with testing-Cloud-Providers\SeleniumGrid
- Verifying Javascript Errors from browser
- Enabling Performance Log for Chrome
- Azure DevOps Support
- Edge browser Support
- Downloading and running Selenium Grid with Powershell
- Run Ocaramba tests with Docker container
- HTTP auth in Internet explorer
- ExtentReports Support