Home > database >  Selenium start chrome and enable extension
Selenium start chrome and enable extension

Time:10-28

We have extension that we are testing and when i run the code with selenium it open the browser with the extension and now i need to enable it with a slide to right.

I thought i can do it with Inspect ( xpath,elemts,id or etc..) but as i can see i don't get the Inspect from the Extension button when i right click on it, and from the extension after that too. enter image description here

But inside the extension i have a Slide to move to the right to start it, on the Slide i can export the Inspect information, but what i need to use to slide it to the right side?

enter image description here

Basically this is how my code starts:

op = Options()
op.add_extension('../extension/extension_21_9_0_0.crx')
driver = webdriver.Chrome(ChromeDriverManager().install(), options=op)
move = ActionChains(driver)
#driver.maximize_window()
time.sleep(2)

driver.get(url)

CodePudding user response:

Selenium cannot target the extensions menu, you can simulate a click using devtools breakpoint controls

2/ Open your extension page in a normal page.

Manually inspect your extension page and on devtools console type document.location That will give you the local extension page chrome is running - for example:

...
href: "chrome-extension://ojhcleddagaoaplflbafhpekcciikdop/popup.html"
origin: "chrome-extension://ojhcleddagaoaplflbafhpekcciikdop"
pathname: "/popup.html"
...

Throw that href in your selenium navigation and you should have a page you can interact with.

Updating the version of the chrome extension does not update that identifier. I've done development on a chrome extension and I've never seen mine change - no idea what it actually takes to update it.

  • Related