Search code examples
selenium-webdriverselenium-chromedriver

How to click on chrome extensions using selenium?


I have to click on chrome Extensions button present in address bar in web automation project. I have no clue how I can click on it using Selenium Webdriver.

Please check attached screen shot for your reference.

Below code snippet which I am using, but not sure click I can click on Extensions button?

System.setProperty(
                "webdriver.chrome.driver",
                "D:\\drivers\\chromedriver.exe");
        
        ChromeOptions options = new ChromeOptions ();

        options.addExtensions (new File("D:\\CRX-Extractor-Downloader.crx"));

        DesiredCapabilities capabilities = new DesiredCapabilities ();

        capabilities.setCapability(ChromeOptions.CAPABILITY, options);

        WebDriver driver = new ChromeDriver(capabilities);
        
        driver.manage().window().maximize();
          
        
        driver.get("https://www.google.com");
        
        Thread.sleep(5000);

enter image description here


Solution

  • You can assign a shortcut to the extension you want to click. For example, after = 'CTRL + U' you can send it with sendkeys while the test automation is running on the page.

    How to Open Extensions With a Keyboard Shortcut in Any Browser = https://www.makeuseof.com/open-browser-extensions-keyboard-shortcut/