@@ -5338,6 +5338,11 @@ def jquery_click_all(self, selector, by="css selector"):
5338
5338
def hide_element(self, selector, by="css selector"):
5339
5339
"""Hide the first element on the page that matches the selector."""
5340
5340
self.__check_scope()
5341
+ try:
5342
+ self.wait_for_element_visible("body", timeout=1.5)
5343
+ self.wait_for_element_present(selector, by=by, timeout=0.5)
5344
+ except Exception:
5345
+ pass
5341
5346
selector, by = self.__recalculate_selector(selector, by)
5342
5347
css_selector = self.convert_to_css_selector(selector, by=by)
5343
5348
if ":contains(" in css_selector:
@@ -5356,6 +5361,10 @@ def hide_element(self, selector, by="css selector"):
5356
5361
def hide_elements(self, selector, by="css selector"):
5357
5362
"""Hide all elements on the page that match the selector."""
5358
5363
self.__check_scope()
5364
+ try:
5365
+ self.wait_for_element_visible("body", timeout=1.5)
5366
+ except Exception:
5367
+ pass
5359
5368
selector, by = self.__recalculate_selector(selector, by)
5360
5369
css_selector = self.convert_to_css_selector(selector, by=by)
5361
5370
if ":contains(" in css_selector:
@@ -5377,6 +5386,11 @@ def hide_elements(self, selector, by="css selector"):
5377
5386
def show_element(self, selector, by="css selector"):
5378
5387
"""Show the first element on the page that matches the selector."""
5379
5388
self.__check_scope()
5389
+ try:
5390
+ self.wait_for_element_visible("body", timeout=1.5)
5391
+ self.wait_for_element_present(selector, by=by, timeout=1)
5392
+ except Exception:
5393
+ pass
5380
5394
selector, by = self.__recalculate_selector(selector, by)
5381
5395
css_selector = self.convert_to_css_selector(selector, by=by)
5382
5396
if ":contains(" in css_selector:
@@ -5396,6 +5410,10 @@ def show_element(self, selector, by="css selector"):
5396
5410
def show_elements(self, selector, by="css selector"):
5397
5411
"""Show all elements on the page that match the selector."""
5398
5412
self.__check_scope()
5413
+ try:
5414
+ self.wait_for_element_visible("body", timeout=1.5)
5415
+ except Exception:
5416
+ pass
5399
5417
selector, by = self.__recalculate_selector(selector, by)
5400
5418
css_selector = self.convert_to_css_selector(selector, by=by)
5401
5419
if ":contains(" in css_selector:
@@ -5417,6 +5435,11 @@ def show_elements(self, selector, by="css selector"):
5417
5435
def remove_element(self, selector, by="css selector"):
5418
5436
"""Remove the first element on the page that matches the selector."""
5419
5437
self.__check_scope()
5438
+ try:
5439
+ self.wait_for_element_visible("body", timeout=1.5)
5440
+ self.wait_for_element_present(selector, by=by, timeout=0.5)
5441
+ except Exception:
5442
+ pass
5420
5443
selector, by = self.__recalculate_selector(selector, by)
5421
5444
css_selector = self.convert_to_css_selector(selector, by=by)
5422
5445
if ":contains(" in css_selector:
@@ -5436,6 +5459,10 @@ def remove_element(self, selector, by="css selector"):
5436
5459
def remove_elements(self, selector, by="css selector"):
5437
5460
"""Remove all elements on the page that match the selector."""
5438
5461
self.__check_scope()
5462
+ try:
5463
+ self.wait_for_element_visible("body", timeout=1.5)
5464
+ except Exception:
5465
+ pass
5439
5466
selector, by = self.__recalculate_selector(selector, by)
5440
5467
css_selector = self.convert_to_css_selector(selector, by=by)
5441
5468
if ":contains(" in css_selector:
0 commit comments