Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(actions): add two selector regex matching cases (#114335)

Thomas Obermüller6cf4a273aa4f
diff --git a/posthog/models/test/test_event_model.py b/posthog/models/test/test_event_model.py
index 996f228faa70..820fa41347f0 100644
--- a/posthog/models/test/test_event_model.py
+++ b/posthog/models/test/test_event_model.py
@@ -261,6 +261,15 @@ class TestSelectorRegexMatching(SimpleTestCase):
],
False,
),
+ (
+ "a tag and a class on different elements",
+ 'button.btn[type="submit"]',
+ [
+ Element(tag_name="button"),
+ Element(tag_name="div", attr_class=["btn"], attributes={"attr__type": "submit"}),
+ ],
+ False,
+ ),
(
"two attributes followed by a class the element does not have",
'button[type="button"][data-x="a"].active',
@@ -309,6 +318,12 @@ class TestSelectorRegexMatching(SimpleTestCase):
[Element(tag_name="button", attributes={"attr__aria-label": "Save"})],
True,
),
+ (
+ "two attributes after a tag and a position",
+ 'button:nth-child(2)[type="button"][data-x="a"]',
+ [Element(tag_name="button", nth_child=2, attributes={"attr__data-x": "a", "attr__type": "button"})],
+ True,
+ ),
(
"two attributes after a tag and a position the element does not have",
'button:nth-child(2)[type="button"][data-x="a"]',