selenium-query 0.3.3__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {selenium_query-0.3.3 → selenium_query-0.4.0}/PKG-INFO +1 -1
- {selenium_query-0.3.3 → selenium_query-0.4.0}/pyproject.toml +1 -1
- selenium_query-0.4.0/selenium_query/__version__.py +1 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_basics/generic_value_getter.py +9 -1
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/base_selenium_page.py +21 -2
- selenium_query-0.3.3/selenium_query/__version__.py +0 -1
- {selenium_query-0.3.3 → selenium_query-0.4.0}/LICENSE +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/README.md +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/__init__.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_any_all_getters.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_asserter_getter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_basics/__init__.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_basics/action_getter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_basics/base_getter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_basics/boolean_getter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_filter_getter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_mapper_getter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_negation_transmitter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_order_getter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_types_and_tools.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_values_getter.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/colors.py +0 -0
- {selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/getter.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.0"
|
{selenium_query-0.3.3 → selenium_query-0.4.0}/selenium_query/_basics/generic_value_getter.py
RENAMED
|
@@ -94,7 +94,15 @@ class ComparerGetter(BaseGetter):
|
|
|
94
94
|
|
|
95
95
|
def css(self, dct=None, **kwargs:Any):
|
|
96
96
|
expectations = self._merge_args(dct,kwargs).items()
|
|
97
|
-
return self._check_elements(expectations,
|
|
97
|
+
return self._check_elements(expectations, self._get_computed_css)
|
|
98
|
+
|
|
99
|
+
def _get_computed_css(self, element:WebElement, name:str):
|
|
100
|
+
""" FIX non FF browser: computed css properties are not accessible with value_of_css_property... """
|
|
101
|
+
if not name.startswith('--') or self.driver.capabilities['browserName'] == 'firefox':
|
|
102
|
+
return element.value_of_css_property(name)
|
|
103
|
+
return self.run_js(
|
|
104
|
+
f"return getComputedStyle(arguments[0]).getPropertyValue({name!r})", element
|
|
105
|
+
)
|
|
98
106
|
|
|
99
107
|
def data(self, dct=None, **kwargs:Any):
|
|
100
108
|
expectations = {'data-'+s: v for s,v in self._merge_args(dct,kwargs).items()}
|
|
@@ -15,10 +15,11 @@ GNU General Public License for more details.
|
|
|
15
15
|
You should have received a copy of the GNU General Public License
|
|
16
16
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
"""
|
|
18
|
-
|
|
18
|
+
import datetime as dt
|
|
19
19
|
from functools import wraps
|
|
20
20
|
from typing import Callable, ClassVar, Tuple, Union, Optional
|
|
21
21
|
|
|
22
|
+
from selenium.common.exceptions import NoAlertPresentException
|
|
22
23
|
from selenium.webdriver.common.alert import Alert
|
|
23
24
|
from selenium.webdriver.remote.webdriver import WebDriver
|
|
24
25
|
from selenium.webdriver.support.wait import WebDriverWait
|
|
@@ -88,6 +89,8 @@ class BaseSeleniumPage:
|
|
|
88
89
|
_getter: ClassVar[Getter]
|
|
89
90
|
_waiter: ClassVar[WebDriverWait]
|
|
90
91
|
|
|
92
|
+
is_firefox: ClassVar[bool]
|
|
93
|
+
|
|
91
94
|
|
|
92
95
|
#----------------------------------------------------------------------------------------------
|
|
93
96
|
|
|
@@ -189,7 +192,7 @@ class BaseSeleniumPage:
|
|
|
189
192
|
|
|
190
193
|
if url == cls._LAST_LOADED_PAGE:
|
|
191
194
|
return
|
|
192
|
-
|
|
195
|
+
BaseSeleniumPage.is_firefox = driver.capabilities['browserName'] == 'firefox'
|
|
193
196
|
BaseSeleniumPage._LAST_LOADED_PAGE = url
|
|
194
197
|
BaseSeleniumPage.driver = driver
|
|
195
198
|
BaseSeleniumPage._waiter = WebDriverWait(driver, 25, poll_frequency=0.2)
|
|
@@ -260,6 +263,20 @@ class BaseSeleniumPage:
|
|
|
260
263
|
return cls._waiter.until(lambda driver: driver.switch_to.alert)
|
|
261
264
|
|
|
262
265
|
|
|
266
|
+
@classmethod
|
|
267
|
+
def safer_wait_for_alert(cls, timeout=10) -> Alert :
|
|
268
|
+
limit = dt.datetime.now() + dt.timedelta(seconds=timeout)
|
|
269
|
+
alert = None
|
|
270
|
+
while not alert and dt.datetime.now() <= limit:
|
|
271
|
+
try:
|
|
272
|
+
alert = cls.wait_until(lambda _: cls.driver.switch_to.alert)
|
|
273
|
+
except NoAlertPresentException:
|
|
274
|
+
continue
|
|
275
|
+
if not alert:
|
|
276
|
+
raise TimeoutError("Couldn't find the Alert in time...")
|
|
277
|
+
return alert
|
|
278
|
+
|
|
279
|
+
|
|
263
280
|
@classmethod
|
|
264
281
|
def wait_for_element(cls, css_selector:str, as_="", *, timeout=None, error=False):
|
|
265
282
|
return cls._getter.wait_for_element(css_selector, as_=as_, timeout=timeout, error=error)
|
|
@@ -292,8 +309,10 @@ class BaseSeleniumPage:
|
|
|
292
309
|
return False
|
|
293
310
|
else:
|
|
294
311
|
return cls.page_is_ready(driver)
|
|
312
|
+
|
|
295
313
|
_page_with_alert_is_ready = page_with_alert_is_ready # alias for backward compatibility
|
|
296
314
|
|
|
315
|
+
|
|
297
316
|
@classmethod
|
|
298
317
|
def run_js(cls, code:str, *args, async_=False, with_promise=True):
|
|
299
318
|
"""
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|