编辑:故障排除的新方向。原始问题将保持在虚线下方。
经过进一步调查后,我意识到这是我的截图导致了崩溃。我正在使用protractor-jasmine2-screenshot-reporter来生成有关失败的测试用例的报告和截图。因此,当规范失败时,它会截取屏幕截图,并使用Chrome进行崩溃。
我找到了一个包含以下内容的调试日志:
[1026/090128:ERROR:process_reader_win.cc(114)] NtOpenThread: {Access Denied} A process has requested access to an object, but has not been granted those access rights. (0xc0000022)
[1026/090128:ERROR:exception_snapshot_win.cc(87)] thread ID 46316 not found in process
[1026/090128:WARNING:crash_report_exception_handler.cc(56)] ProcessSnapshotWin::Initialize failed
[1026/093428:ERROR:process_reader_win.cc(114)] NtOpenThread: {Access Denied} A process has requested access to an object, but has not been granted those access rights. (0xc0000022)
以下是报告工具
中index.js的代码this.specDone = function (spec) {
spec.filename = {};
spec = getSpecClone(spec);
spec._finished = Date.now();
if (!isSpecValid(spec)) {
spec.skipPrinting = true;
return;
}
_.each(browser.forkedInstances, function (browserInstance, key) {
if (!browserInstance) return;
browserInstance.takeScreenshot().then(function (png) {
browserInstance.getCapabilities().then(function (capabilities) {
var screenshotPath,
metadataPath,
metadata;
var file = opts.pathBuilder(spec, suites, capabilities);
spec.filename[key] = file + '.png';
screenshotPath = path.join(opts.dest, spec.filename[key]);
metadata = opts.metadataBuilder(spec, suites, capabilities);
if (metadata) {
metadataPath = path.join(opts.dest, file + '.json');
mkdirp(path.dirname(metadataPath), function (err) {
if (err) {
throw new Error('Could not create directory for ' + metadataPath);
}
writeMetadata(metadata, metadataPath);
});
}
mkdirp(path.dirname(screenshotPath), function (err) {
if (err) {
throw new Error('Could not create directory for ' + screenshotPath);
}
writeScreenshot(png, spec.filename[key]);
});
});
});
});
};
问题来自 browserInstance.takeScreenshot()
行所以新问题是:如何授予Chrome访问权限以允许屏幕截图?
我尝试过“--disable-extensions”和“--disable-web-securities”都没有运气。
ORIGINAL: 一段时间以来,由于“WebDriverError:未知错误:无法获得自动化扩展”问题,我无法在Chrome中运行我的E2E量角器/ Jasmine测试。
以前,在Chrome中运行测试时,它会尝试加载页面,然后只是因上述错误而崩溃。截至最近,我已对我的工具进行了一些更新,至少可以让我的测试再次在Chrome中运行。但是,这次当规范失败并且它没有记录或报告规范时,我会得到相同的自动化扩展错误,也不会继续执行文件中的其余规范。
成功通过的测试工作正常。其中有失败的测试超时并且不记录。任何人都知道这是否仍然是一个浏览器或者我做错了什么?
量角器版本: 4.0.9
NPM版本: 3.10.9
节点版本: 4.4.3
Chrome版本: 54.0.2840.71
ChromeDriver版本: 2.24
Selenium Standalone: 2.53.1
我正在按如下方式直接启动Web服务器:
java -jar C:/.../node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-2.53.1.jar \
-Dwebdriver.chrome.driver=C:/.../node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver.exe \
我的配置文件的位:
multiCapabilities: [
{
'shardTestFiles': 'true',
'browserName': 'chrome',
'ignoreZoomSetting': 'true',
'platform': "ANY",
'marionette': 'true',
'chromeOptions': {
'args': ['start-maximized']
},
},
],
seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect: true,
错误:
[74.302][SEVERE]: Timed out receiving message from renderer: -11.004
13:48:15.377 WARN - Exception thrown
org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension
from timeout: cannot determine loading status
from timeout: Timed out receiving message from renderer: -11.004
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 21.02 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'SIWKSTN18', ip: '10.0.0.165', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_67'
Session ID: a4a6e50c6de395381639c6fa4885a9ab
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=WIN8_1, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=C:\Users\DRODRI~1\AppData\Local\Temp\scoped_dir200_9106, chromedriverVersion=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf)}, networkConnectionEnabled=false, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=54.0.2840.71, pageLoadStrategy=normal, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, hasTouchScreen=false, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:335)
at org.openqa.selenium.remote.server.handler.CaptureScreenshot.call(CaptureScreenshot.java:36)
at org.openqa.selenium.remote.server.handler.CaptureScreenshot.call(CaptureScreenshot.java:1)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
13:48:15.378 WARN - Exception: unknown error: cannot get automation extension
from timeout: cannot determine loading status
from timeout: Timed out receiving message from renderer: -11.004
答案 0 :(得分:0)
当量角器读入您的配置时,它会看到您已将directConnect
设置为true。它会尝试通过直接连接启动Chrome(请参阅runner.ts)。 Protractor将假定的文件是webdriver-manager下载的文件路径。所以它可能正在寻找chromedriver_2.24.exe
。
我对您的配置和启动语句感到困惑。您的发布时间为chromedriver.exe
。文件名也应附加版本号。所以我不确定直接连接是如何工作的以及如何获取这些日志语句。
此外,您似乎希望根据Java启动命令使用selenium独立功能。您需要做的是从配置中删除directConnect
属性。