|
1 | 1 | import asyncio
|
2 |
| -from typing import TYPE_CHECKING, Optional, TypeVar, Union |
| 2 | +from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union, overload |
3 | 3 |
|
4 | 4 | from pydoll.commands import (
|
5 | 5 | DomCommands,
|
@@ -44,6 +44,76 @@ class FindElementsMixin:
|
44 | 44 | complex location logic themselves.
|
45 | 45 | """
|
46 | 46 |
|
| 47 | + @overload |
| 48 | + async def find( |
| 49 | + self, |
| 50 | + id: Optional[str] = ..., |
| 51 | + class_name: Optional[str] = ..., |
| 52 | + name: Optional[str] = ..., |
| 53 | + tag_name: Optional[str] = ..., |
| 54 | + text: Optional[str] = ..., |
| 55 | + timeout: int = ..., |
| 56 | + find_all: Literal[False] = False, |
| 57 | + raise_exc: Literal[True] = True, |
| 58 | + **attributes: dict[str, str], |
| 59 | + ) -> 'WebElement': ... |
| 60 | + |
| 61 | + @overload |
| 62 | + async def find( |
| 63 | + self, |
| 64 | + id: Optional[str] = ..., |
| 65 | + class_name: Optional[str] = ..., |
| 66 | + name: Optional[str] = ..., |
| 67 | + tag_name: Optional[str] = ..., |
| 68 | + text: Optional[str] = ..., |
| 69 | + timeout: int = ..., |
| 70 | + find_all: Literal[True] = True, |
| 71 | + raise_exc: Literal[True] = True, |
| 72 | + **attributes: dict[str, str], |
| 73 | + ) -> list['WebElement']: ... |
| 74 | + |
| 75 | + @overload |
| 76 | + async def find( |
| 77 | + self, |
| 78 | + id: Optional[str] = ..., |
| 79 | + class_name: Optional[str] = ..., |
| 80 | + name: Optional[str] = ..., |
| 81 | + tag_name: Optional[str] = ..., |
| 82 | + text: Optional[str] = ..., |
| 83 | + timeout: int = ..., |
| 84 | + find_all: Literal[True] = True, |
| 85 | + raise_exc: Literal[False] = False, |
| 86 | + **attributes: dict[str, str], |
| 87 | + ) -> Optional[list['WebElement']]: ... |
| 88 | + |
| 89 | + @overload |
| 90 | + async def find( |
| 91 | + self, |
| 92 | + id: Optional[str] = ..., |
| 93 | + class_name: Optional[str] = ..., |
| 94 | + name: Optional[str] = ..., |
| 95 | + tag_name: Optional[str] = ..., |
| 96 | + text: Optional[str] = ..., |
| 97 | + timeout: int = ..., |
| 98 | + find_all: Literal[False] = False, |
| 99 | + raise_exc: Literal[False] = False, |
| 100 | + **attributes: dict[str, str], |
| 101 | + ) -> Optional['WebElement']: ... |
| 102 | + |
| 103 | + @overload |
| 104 | + async def find( |
| 105 | + self, |
| 106 | + id: Optional[str] = ..., |
| 107 | + class_name: Optional[str] = ..., |
| 108 | + name: Optional[str] = ..., |
| 109 | + tag_name: Optional[str] = ..., |
| 110 | + text: Optional[str] = ..., |
| 111 | + timeout: int = ..., |
| 112 | + find_all: bool = ..., |
| 113 | + raise_exc: bool = ..., |
| 114 | + **attributes: dict[str, str], |
| 115 | + ) -> Union['WebElement', list['WebElement'], None]: ... |
| 116 | + |
47 | 117 | async def find( # noqa: PLR0913, PLR0917
|
48 | 118 | self,
|
49 | 119 | id: Optional[str] = None,
|
@@ -101,6 +171,51 @@ async def find( # noqa: PLR0913, PLR0917
|
101 | 171 | by, value, timeout=timeout, find_all=find_all, raise_exc=raise_exc
|
102 | 172 | )
|
103 | 173 |
|
| 174 | + @overload |
| 175 | + async def query( |
| 176 | + self, |
| 177 | + expression: str, |
| 178 | + timeout: int = ..., |
| 179 | + find_all: Literal[False] = False, |
| 180 | + raise_exc: Literal[True] = True, |
| 181 | + ) -> 'WebElement': ... |
| 182 | + |
| 183 | + @overload |
| 184 | + async def query( |
| 185 | + self, |
| 186 | + expression: str, |
| 187 | + timeout: int = ..., |
| 188 | + find_all: Literal[False] = False, |
| 189 | + raise_exc: Literal[False] = False, |
| 190 | + ) -> Optional['WebElement']: ... |
| 191 | + |
| 192 | + @overload |
| 193 | + async def query( |
| 194 | + self, |
| 195 | + expression: str, |
| 196 | + timeout: int = ..., |
| 197 | + find_all: Literal[True] = True, |
| 198 | + raise_exc: Literal[True] = True, |
| 199 | + ) -> list['WebElement']: ... |
| 200 | + |
| 201 | + @overload |
| 202 | + async def query( |
| 203 | + self, |
| 204 | + expression: str, |
| 205 | + timeout: int = ..., |
| 206 | + find_all: Literal[True] = True, |
| 207 | + raise_exc: Literal[False] = False, |
| 208 | + ) -> Optional[list['WebElement']]: ... |
| 209 | + |
| 210 | + @overload |
| 211 | + async def query( |
| 212 | + self, |
| 213 | + expression: str, |
| 214 | + timeout: int = ..., |
| 215 | + find_all: bool = ..., |
| 216 | + raise_exc: bool = ..., |
| 217 | + ) -> Union['WebElement', list['WebElement'], None]: ... |
| 218 | + |
104 | 219 | async def query(
|
105 | 220 | self, expression: str, timeout: int = 0, find_all: bool = False, raise_exc: bool = True
|
106 | 221 | ) -> Union['WebElement', list['WebElement'], None]:
|
|
0 commit comments