Skip to content

Commit 3b1d438

Browse files
committed
Update the built-in ad-blocker
1 parent 4fac090 commit 3b1d438

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

seleniumbase/config/ad_block_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"[data-google-av-adk]",
7070
"[data-google-query-id]",
7171
'[data-ylk*="sponsored_cluster"]',
72-
'[data-google-av-cxn*="pagead"]',
72+
"[data-google-av-cxn]",
7373
"[data-ad-client]",
7474
"[data-ad-slot]",
7575
'[href*="doubleclick"]',
@@ -108,4 +108,5 @@
108108
'link[href*="/adservice."]',
109109
"section.dianomi-ad",
110110
"ytd-promoted-video-renderer",
111+
"ytd-video-masthead-ad-v3-renderer",
111112
]

seleniumbase/fixtures/base_case.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,10 +2900,10 @@ def wait_for_ready_state_complete(self, timeout=None):
29002900
# For Chromium browsers in headed mode, the extension is used
29012901
current_url = self.get_current_url()
29022902
if not current_url == self.__last_page_load_url:
2903-
self.ad_block()
2904-
if self.is_element_present("iframe"):
2905-
time.sleep(0.1) # iframe ads take slightly longer to load
2906-
self.ad_block() # Do ad_block on slower-loading iframes
2903+
if page_actions.is_element_present(
2904+
self.driver, "iframe", By.CSS_SELECTOR
2905+
):
2906+
self.ad_block()
29072907
self.__last_page_load_url = current_url
29082908
return is_ready
29092909

@@ -3813,7 +3813,7 @@ def ad_block(self):
38133813
""" Block ads that appear on the current web page. """
38143814
from seleniumbase.config import ad_block_list
38153815

3816-
self.__check_scope()
3816+
self.__check_scope() # Using wait_for_RSC would cause an infinite loop
38173817
for css_selector in ad_block_list.AD_BLOCK_LIST:
38183818
css_selector = re.escape(css_selector) # Add "\\" to special chars
38193819
css_selector = self.__escape_quotes_if_needed(css_selector)

seleniumbase/plugins/pytest_plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ def pytest_addoption(parser):
627627
every page load.""",
628628
)
629629
parser.addoption(
630+
"--adblock",
630631
"--ad_block",
631632
"--ad-block",
632633
"--block_ads",

seleniumbase/plugins/selenium_plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ def options(self, parser, env):
388388
every page load.""",
389389
)
390390
parser.add_option(
391+
"--adblock",
391392
"--ad_block",
392393
"--ad-block",
393394
"--block_ads",

0 commit comments

Comments
 (0)