Skip to content

Commit

Permalink
fix: getChromeExtensionPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonghakseo committed Nov 22, 2024
1 parent 5bf1fdd commit fd41d42
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/e2e/utils/extension-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@
*/
export const getChromeExtensionPath = async (browser: WebdriverIO.Browser) => {
await browser.url('chrome://extensions/');
const extensionItem = await $('extensions-item').getElement();
/**
* https://webdriver.io/docs/extension-testing/web-extensions/#test-popup-modal-in-chrome
* ```ts
* const extensionItem = await $('extensions-item').getElement();
* ```
* The above code is not working. I guess it's because the shadow root is not accessible.
* So I used the following code to access the shadow root manually.
*
* @url https://github.com/webdriverio/webdriverio/issues/13521
* @url https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite/issues/786
*/
const extensionItem = await (async () => {
const extensionsManager = await $('extensions-manager').getElement();
const itemList = await extensionsManager.shadow$('#container > #viewManager > extensions-item-list');
return await itemList.shadow$('extensions-item');
})();

const extensionId = await extensionItem.getAttribute('id');

if (!extensionId) {
Expand Down

0 comments on commit fd41d42

Please sign in to comment.