Repository: Textualize/textual

Issue:
Pilot.click can't use `Screen` as selector.
If you try something like `pilot.click(Screen)`, you get a `NoMatches` exception from the query.

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 35a0624f8..c401104de 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](http://keepachangelog.com/)
 and this project adheres to [Semantic Versioning](http://semver.org/).
 
+## Unreleased
+
+### Fixed
+
+- `Pilot.click`/`Pilot.hover` can't use `Screen` as a selector https://github.com/Textualize/textual/issues/3395
+
 ## [0.38.1] - 2023-09-21
 
 ### Fixed
diff --git a/src/textual/pilot.py b/src/textual/pilot.py
index c3c64d2e9..c15441d0b 100644
--- a/src/textual/pilot.py
+++ b/src/textual/pilot.py
@@ -100,7 +100,7 @@ class Pilot(Generic[ReturnType]):
         app = self.app
         screen = app.screen
         if selector is not None:
-            target_widget = screen.query_one(selector)
+            target_widget = app.query_one(selector)
         else:
             target_widget = screen
 
@@ -132,7 +132,7 @@ class Pilot(Generic[ReturnType]):
         app = self.app
         screen = app.screen
         if selector is not None:
-            target_widget = screen.query_one(selector)
+            target_widget = app.query_one(selector)
         else:
             target_widget = screen
 


Test patch:
diff --git a/tests/test_pilot.py b/tests/test_pilot.py
index d631146c7..322146127 100644
--- a/tests/test_pilot.py
+++ b/tests/test_pilot.py
@@ -52,3 +52,21 @@ async def test_pilot_exception_catching_action():
     with pytest.raises(ZeroDivisionError):
         async with FailingApp().run_test() as pilot:
             await pilot.press("b")
+
+
+async def test_pilot_click_screen():
+    """Regression test for https://github.com/Textualize/textual/issues/3395.
+
+    Check we can use `Screen` as a selector for a click."""
+
+    async with App().run_test() as pilot:
+        await pilot.click("Screen")
+
+
+async def test_pilot_hover_screen():
+    """Regression test for https://github.com/Textualize/textual/issues/3395.
+
+    Check we can use `Screen` as a selector for a hover."""
+
+    async with App().run_test() as pilot:
+        await pilot.hover("Screen")