-
Notifications
You must be signed in to change notification settings - Fork 130
Verifying Javascript Errors from browser
Note: this function is temporarily not working due to an issue within Selenium: https://github.com/SeleniumHQ/selenium/issues/7900
Our test framework supports Javascript error logging from a browser. In case of any defined Javascript error, the test will fail and log details. To enable Javascript error logging you have to set below flag to trues (default) in App.config file:
<add key="JavaScriptErrorLogging" value="true"/>
You can also define which Javascript errors will fail the test (also configurable from App.config file). Those ones are defined by default:
<add key="JavaScriptErrorTypes" value="SyntaxError,EvalError,ReferenceError,RangeError,TypeError,URIError,Refused to display,Internal Server Error,Cannot read property" />
In case of fail you will see below message:
Message: JavaScript errors found. See the logs for details.>
And details in a log file:
2018-02-05 10:02:34.3895|Error|Ocaramba.DriverContext.LogJavaScriptErrors|JavaScript error(s): http://the-internet.herokuapp.com/javascript_error 6:51 Uncaught TypeError: Cannot read property 'xyz' of undefined>
Javascript errors are check in ProjectTestBase class in AfterTest() method.
public void AfterTest()
{
this.DriverContext.IsTestFailed = TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed || !this.driverContext.VerifyMessages.Count.Equals(0);
var filePaths = this.SaveTestDetailsIfTestFailed(this.driverContext);
this.SaveAttachmentsToTestContext(filePaths);
this.LogTest.LogTestEnding(this.driverContext);
var javaScriptErrors = this.DriverContext.LogJavaScriptErrors();
if (this.IsVerifyFailedAndClearMessages(this.driverContext) && TestContext.CurrentContext.Result.Outcome.Status != TestStatus.Failed)
{
Assert.Fail();
}
if (javaScriptErrors)
{
Assert.Fail("JavaScript errors found. See the logs for details");
}
}
- 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