I am trying to add a chrome extension to robot framework. I am using the keyword Open Browser (by adding the desired_capabilities) but when I run this code no extension is added (but no error occurs). I checked the path for the crx file and it should be correct.
*** Settings ***
Library SeleniumLibrary
Library Process
Library Collections
Suite Teardown Close Browser
***Variables***
${BROWSER} Chrome
${SELENIUM} http://hub:4444/wd/hub
*** Test Cases ***
Open Chrome with extension
${options} = Create List add_extension ${CURDIR}/office-extension.crx
${arguments} = Create Dictionary args=${options}
${capabilities} = Create Dictionary chromeOptions=${arguments}
Open Browser chrome://extensions/ remote_url=${SELENIUM} browser=${BROWSER} desired_capabilities=${capabilities}
Capture Page Screenshot
This work for me:
*** Test Cases ***
Open Chrome with extension
${ChromeOptions} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${ChromeOptions} add_argument remote-debugging-port\=9222
Call Method ${ChromeOptions} add_argument ${args}
Call Method ${ChromeOptions} add_extension ${EXECDIR}${/}Resources${/}BrowserAddons${/}test1.crx
${Options}= Call Method ${ChromeOptions} to_capabilities
Create Webdriver Chrome desired_capabilities=${Options}
Go to about:blank
Maximize Browser Window
Here with the open Browser keyword
Open Chrome with extension
${ChromeOptions} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${ChromeOptions} add_argument remote-debugging-port\=9222
Call Method ${ChromeOptions} add_argument ${args}
Call Method ${ChromeOptions} add_extension ${EXECDIR}{/}test1.crx
${Options}= Call Method ${ChromeOptions} to_capabilities
Open Browser about:blank Chrome desired_capabilities=${Options}
Maximize Browser Window
You don't have to use the remote-debugging-port\=9222, this is something I have to do otherwise chrome wouldn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With