I am able to load a chrome extension through CRX file and successfully add it to the chrome with selenium webdriver using java with Chrome Options, can anyone tell me how to automate to click the extension once it added to the chrome. Every time i have to click manually on the extension for the further process of automation.
-
This answers your question: https://stackoverflow.com/a/63719005/7698734 – Hassaan Ali Sep 04 '20 at 09:51
1 Answers
Not sure how you are doing it. Try loading the extension using ChromeOptions, it loads the browser with extension and there is no need to click any button manually
ChromeOptions options = new ChromeOptions();
//Adding Chrome extension
options.addExtensions(new File("Chrome extension - crx file path"));
options.addArguments("--start-maximized");
options.addArguments("--test-type");
System.setProperty("webdriver.chrome.driver", "path to/chromedriver.exe");
driver = new ChromeDriver(options);
Just FYI - handling OS level controls is out of reach of Selenium.
To handle OS level controls you can use AutoIT or LDTP. Personally I prefer LDTP for smaller interaction as it gives seamless experience and is platform independent - https://github.com/ldtp/cobra
You can also try Pywinauto, a python library. With pywinauto you write the code to handle the OS level control and call this python script from Java code. For most of the tools you need to install their executables but for Pywinauto you only need Python to be installed which is approved to use in most of the organizations. For basic pywinauto script you need not learn the language. Refer https://pywinauto.readthedocs.io/en/latest/

- 396
- 6
- 9
-
chromeOptions = new ChromeOptions(); chromeOptions.setBinary("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"); chromeOptions.addExtensions(new File(System.getProperty("user.dir") + (Config.getProperty("ExtenstionCRX")))); log.debug("Extention has been added"); chromeOptions.addArguments("auto-select-desktop-capture-source=Entire screen"); chromeOptions.addArguments("test-type"); driver = new ChromeDriver(chromeOptions); – Umang Mishra Sep 04 '20 at 02:45
-
Thanks Rohit but what you mentioned i already done it What i need is to click the extension icon through selenium – Umang Mishra Sep 04 '20 at 02:48
-
@UmangMishra it would be helpful if you can post a screenshot of what you are trying to click and when/why there's a need to click the extension icon – Rohit Sep 04 '20 at 03:19
-
i solved it i used the sikuli, so with the help of sikuli i am able to click the button or extension outside the webpage. – Umang Mishra Sep 05 '20 at 07:17
-
Good if it works for but looking at Sikuli's shortcomings it may not be wise choice though. – Rohit Sep 07 '20 at 10:13