1

I installed Goggle analytic debugger ( https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna ) on chrome browser & getting ON / OFF switch on top right corner( extension icon bar) on chrome browser. Can we automate this ON /OFF action via selenium web driver.

Is there any way to automate this on /off action

parveen
  • 11
  • 1

1 Answers1

0

Below is the solution is in Python with pyautogui (I think it's similar to autoit - so you can extend the same solution for your specific language also).

Pre-Condition:

save the extension image in the project folder (I saved it under "autogui_ref_snaps" folder in my example with "capture_full_screenshot.png" name

Python:

Imports needed

from selenium import webdriver
from selenium.webdriver import ChromeOptions
from Common_Methods.GenericMethods import *
import pyautogui  #<== need this to click on extension

Script:

options = ChromeOptions()
options.add_argument("--load-extension=" + r"C:\Users\supputuri\AppData\Local\Google\Chrome\User Data\Default\Extensions\fdpohaocaechififmbbbbbknoalclacl\5.1_0") #<== loading unpacked extension

driver = webdriver.Chrome(
executable_path=os.path.join(chrome_options=options)
url = "https://google.com/"
driver.get(url)

# get the extension box
extn = pyautogui.locateOnScreen(os.path.join(GenericMethods.get_full_path_to_folder('autogui_ref_snaps') + "/capture_full_screenshot.png"))
# click on extension 
pyautogui.click(x=extn[0],y=extn[1],clicks=1,interval=0.0,button="left")

If you are loading an extension and it's not available in incognito mode then follow my answer in here to enable it.

supputuri
  • 13,644
  • 2
  • 21
  • 39