Chromedriver扩展ID与manifest.json中的键不匹配 [英] Chromedriver extension id does not match key in manifest.json

查看:467
本文介绍了Chromedriver扩展ID与manifest.json中的键不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用selenium webdriver.js和chromedriver测试Chrome扩展。我已经能够成功地启动chrome,并安装了我的扩展,但扩展id是随机生成的,而不是匹配我的manifest.json的属性。这使得无法测试扩展页面,如选项页面。



manifest.json

  // ... 
key:pjnhffdkdckcagdmfmidafhppbomjdjg,// chrome网店中的id
// ...

test.js $ b

  var webdriver = require('selenium-webdriver'); 
var chrome = require('selenium-webdriver / chrome');

//载入解包的扩展名
var chromeOptions = new chrome.Options();
chromeOptions.addArguments('load-extension = / path / to / my / extension');

var service = new chrome.ServiceBuilder()。build();
var driver = chrome.createDriver(chromeOptions,service)
//此页面不可用T_T
driver.get('chrome-extension://pjnhffdkdckcagdmfmidafhppbomjdjg/html/options.html' );

我的假设是,扩展名id与密钥匹配(并且从网上商店),但这似乎不适用于通过chromedriver加载扩展。有没有办法让加载的扩展具有一致的ID?或者我应该采取另一种方法?

解决方案

清单值是不是扩展名。您必须从网上商店安装扩展程序,然后查看桌面上的manifest.json文件。在该文件中使用它们 key 值。 文档介绍了如何找到安装目录。


I am testing a chrome extension using selenium webdriver.js and chromedriver. I've been able to successfully launch chrome, with my extension installed, but the extension id is randomly generated instead of matching the key property of my manifest.json. This makes it impossible to test extension pages like the options page.

manifest.json

// ...
"key": "pjnhffdkdckcagdmfmidafhppbomjdjg", // id from chrome web store
// ...

test.js

var webdriver = require('selenium-webdriver');
var chrome = require('selenium-webdriver/chrome');

// load unpacked extension
var chromeOptions = new chrome.Options();
chromeOptions.addArguments('load-extension=/path/to/my/extension');

var service = new chrome.ServiceBuilder().build();
var driver = chrome.createDriver(chromeOptions, service)
// this page is not available T_T
driver.get('chrome-extension://pjnhffdkdckcagdmfmidafhppbomjdjg/html/options.html');

My assumption is that the extension id would match the key (and it does when installing from the web store), but this does not seem to be true for loading the extension via chromedriver. Is there a way to get the loaded extension to have a consistent ID? Or should I take another approach?

解决方案

The manifest key value is not the extension ID. You have to install the extension from the web store and look in the manifest.json file on your desk. Use they key value inside that file. The documentation describes how to find the install directory.

这篇关于Chromedriver扩展ID与manifest.json中的键不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆