Skip to content

Commit 1940b83

Browse files
Browser tests self maintenance guide (DataDog#10569)
* Create browser-test-self-maintenance.md * Update _index.md * Update advanced_options.md * Update content/en/synthetics/guide/browser-test-self-maintenance.md * Update content/en/synthetics/guide/browser-test-self-maintenance.md * Update content/en/synthetics/guide/browser-test-self-maintenance.md Co-authored-by: Sarina Bloodgood <57639676+sarina-dd@users.noreply.github.com> * Update content/en/synthetics/guide/browser-test-self-maintenance.md Co-authored-by: Sarina Bloodgood <57639676+sarina-dd@users.noreply.github.com> * Update content/en/synthetics/guide/browser-test-self-maintenance.md Co-authored-by: Sarina Bloodgood <57639676+sarina-dd@users.noreply.github.com> * Update content/en/synthetics/guide/browser-test-self-maintenance.md Co-authored-by: Sarina Bloodgood <57639676+sarina-dd@users.noreply.github.com> Co-authored-by: Sarina Bloodgood <57639676+sarina-dd@users.noreply.github.com>
1 parent 2f3da87 commit 1940b83

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

content/en/synthetics/browser_tests/advanced_options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ further_reading:
1010

1111
## User specified locator
1212

13-
By default, [browser tests][1] use the Datadog locator system. It is recommended to only use custom selectors in edge cases as the Datadog locator system is what allows tests to be self-maintaining.
13+
By default, browser tests use the [Datadog locator system][1]. It is recommended to only use custom selectors in edge cases as the Datadog locator system is what allows tests to be self-maintaining.
1414

1515
Custom selectors are created by performing a step of interest in the recorder (**click**, **hover**, **assert**, etc.) on any element of your page. This specifies the kind of step that needs to be performed.
1616

@@ -67,7 +67,7 @@ Opening your subtest in the main tab means that your subtest is the continuation
6767

6868
{{< partial name="whats-next/whats-next.html" >}}
6969

70-
[1]: /synthetics/browser_tests/
70+
[1]: /synthetics/guide/browser-test-self-maintenance
7171
[2]: /synthetics/browser_tests/actions/
7272
[3]: /security/synthetics/
7373
[4]: /synthetics/browser_tests/?tab=privacy#test-configuration

content/en/synthetics/guide/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ private: true
1010
{{< /whatsnext >}}
1111

1212
{{< whatsnext desc="Browser Tests:" >}}
13+
{{< nextlink href="synthetics/guide/browser-test-self-maintenance/" >}}Why are browser tests self-maintaining?{{< /nextlink >}}
1314
{{< nextlink href="synthetics/guide/app-that-requires-login/" >}}Monitor an application that requires authentication{{< /nextlink >}}
1415
{{< nextlink href="synthetics/guide/recording-custom-user-agent/" >}}Record steps with a custom User-Agent{{< /nextlink >}}
1516
{{< nextlink href="synthetics/guide/reusing-browser-test-journeys/" >}}Reusing browser tests journeys across your test suite{{< /nextlink >}}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Why are browser tests self-maintaining?
3+
kind: guide
4+
further_reading:
5+
- link: 'synthetics/browser_tests'
6+
tag: 'Documentation'
7+
text: 'Configure a Browser Test'
8+
- link: '/synthetics/browser_tests/actions'
9+
tag: 'Documentation'
10+
text: 'Create Browser Test Steps'
11+
- link: 'https://www.datadoghq.com/blog/test-creation-best-practices/'
12+
tag: 'Blog'
13+
text: 'Best practices for creating end-to-end tests'
14+
15+
---
16+
17+
Flakiness is one of the biggest pain points associated with end-to-end testing. Oftentimes end-to-end tests fail not because of an actual application issue, but because a frontend team performed changes that cause an identifier used by your test not to work anymore.
18+
19+
## How do browser tests target elements?
20+
21+
Datadog’s Synthetic browser tests address this pain point through an in-house algorithm that leverages a set of locators to target elements. When a test searches for a specific element to interact with (for example, a checkout button) instead of looking at an element with a specific XPath or a specific CSS selector, browser tests use several different points of reference to help find it (XPath, text, classes, what other elements are near it, etc.). These points of reference are turned into a set of locators, each uniquely defining the element.
22+
23+
If a small UI change modifies an element (for example, moves it to another location), the test automatically locates the element again based on the points of reference that were not affected by the change. Once the test completes successfully, browser tests recompute, or "self-heal", any broken locators with updated values. This ensures that your tests do not break because of a simple UI change and can automatically adapt to the evolution of your application’s UI.
24+
25+
## How do I make sure my browser test does not validate an unexpected change?
26+
27+
That is exactly why using assertions is so important. Assertions allow you to define what is and is not the expected behavior associated with the journey your test is testing.
28+
29+
## What if I still want to use a specific identifier?
30+
31+
In some rare use cases (for example, if you want to click on the `nth` element of a dropdown menu, regardless of what the content of the element is), it makes sense to have your step rely on a user defined locator.
32+
33+
For this, use the [User Specified Locator][1] feature that is available in the [advanced options][2] of your browser test steps.
34+
35+
## Further Reading
36+
37+
{{< partial name="whats-next/whats-next.html" >}}
38+
39+
[1]: /synthetics/browser_tests/advanced_options/#user-specified-locator
40+
[2]: /synthetics/browser_tests/advanced_options/

0 commit comments

Comments
 (0)