sandrocods / SeleniumAdblock

Easy Package to disable all ads and popup on your selenium automation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SeleniumAdblock

A Package to block ads and popups in your automation testing, inspired from puppeteer-extra-plugin-adblocker Javascript, here i make it in python3 version for Chrome Browser

Acknowledgements

Feature

Name
Small Size Package
Automatic Install to Chrome
Block Ads
Block Popup
Block Redirect

Demo

Without SeleniumAdblocker

2022-11-15.15-48-47.mp4

With SeleniumAdblocker

2022-11-15.15-47-36.mp4

Installation

Installation from source (requires git):

  git clone https://github.com/sandrocods/SeleniumAdblock
  cd SeleniumAdblock
  python setup.py install

or :

  pip install git+https://github.com/sandrocods/SeleniumAdblock.git

Writing Code

  from selenium import webdriver
  import SeleniumAdblock

After import package , create an instance of the SeleniumAdblock class.

  options = SeleniumAdblock.SeleniumAdblock()._startAdBlock()
  # options.add_argument('--disable-blink-features=AutomationControlled')

in options you can add more arguments

Dont add options.add_argument("--disable-extensions") because it will disable the adblock extension

  driver = webdriver.Chrome(options=options) 
  driver.get("https://www.detik.com/")

Example Code : example.py

API Reference

Get all list extension in this package

import SeleniumAdblock

options = SeleniumAdblock.SeleniumAdblock()
for i in options._listaAdBlock():
    print(i)

Start with Another Adblock

import SeleniumAdblock

options = SeleniumAdblock.SeleniumAdblock()._startAdblockList(
    name="AdBlock-best-ad-blocker"
)
Parameter Type Description
name string Required. Name from _listaAdBlock()

Start with Custom extension

import SeleniumAdblock

options = SeleniumAdblock.SeleniumAdblock()._startCustomAdBlock(
    path=r"C:\Users\user\Downloads\Ultimate-Ad-Blocker.crx"
)
Parameter Type Description
path string Required. path of extension

Running Tests

To run tests, run the following command

  cd test
  python3 testAdblock.py

Support

For support, email krisandromartinus@gmail.com / telegram : @sandroputraaa

About

Easy Package to disable all ads and popup on your selenium automation


Languages

Language:Python 100.0%