gpt4 book ai didi

angular - 加载文件 Protractor 失败 - 失败 : script timeout: result was not received in 11 seconds

转载 作者:太空狗 更新时间:2023-10-29 19:31:54 26 4
gpt4 key购买 nike

我在尝试执行测试以使用 Protractor 上传文件时出错,我的代码是这个

    it('it should be possible to upload a file', function() {
browser.get(buildUrl(''));
popupEnvironment();

element(by.id("menu-transmission")).click();
element(by.id("menu-child-send-datafiles")).click();

expect(element(by.id("drop-zone")).isPresent()).toBeTruthy('the drag and drop zone should be present');
expect(element(by.id("drop-zone")).isDisplayed()).toBeTruthy('the drag and drop zone should be present');

expect(element(by.xpath('//*[@id="drop-zone"]/p[3]/label')).isPresent()).toBeTruthy('the Select File button should be present');
expect(element(by.xpath('//*[@id="drop-zone"]/p[3]/label')).isDisplayed()).toBeTruthy('the Select File button should be displayed');

var path = require('path');
var fileToUpload = "./resources/1.txt";
var absolutePath = path.resolve(__dirname, fileToUpload);

//element(by.id('file-upload')).sendKeys(absolutePath);
browser.executeScript("document.getElementById('file-upload').sendKeys(" + absolutePath + ")");

browser.sleep(20000);

});

我尝试使用 element(by.id('file-upload')).sendKeys(absolutePath);但它不起作用,后来我尝试使用 javascript 原始代码,但它也不起作用

我的错误信息是这个,使用命令“ng e2e”

    × it should be possible to upload a file
- Failed: script timeout: result was not received in 11 seconds
(Session info: chrome=72.0.3626.109)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
(Session info: chrome=72.0.3626.109)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
at Object.checkLegacyResponse (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: Protractor.waitForAngular() - Locator: By(css selector, *[id="drop-zone"])
at Driver.schedule (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at ProtractorBrowser.executeAsyncScript_ (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\protractor\built\browser.js:425:28)
at angularAppRoot.then (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\protractor\built\browser.js:456:33)
at ManagedPromise.invokeCallback_ (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:668:7
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: Run it("it should be possible to upload a file") in control flow
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
From asynchronous test:
Error
at Object.transmissionSendDatafile (C:\gitlab\edamis\EDAMIS-portal\src\main\front\e2e\transmissions-send-datafile.ts:26:5)
at Suite.<anonymous> (C:\gitlab\edamis\EDAMIS-portal\src\main\front\e2e\all-access.e2e-spec.ts:37:5)
at Object.<anonymous> (C:\gitlab\edamis\EDAMIS-portal\src\main\front\e2e\all-access.e2e-spec.ts:17:1)
at Module._compile (module.js:643:30)
at Module.m._compile (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\ts-node\src\index.ts:422:23)
at Module._extensions..js (module.js:654:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\ts-node\src\index.ts:425:12)
at Module.load (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\coffeescript\lib\coffee-script\register.js:45:36)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Array.forEach (<anonymous>)
at Function.promise (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:682:9)
at _fulfilled (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:796:13)
at C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:556:49
at runSingle (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:137:13)
at flush (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
× Test that user is allowed to access secure pages
- Failed: script timeout: result was not received in 11 seconds
(Session info: chrome=72.0.3626.109)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
(Session info: chrome=72.0.3626.109)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
at Object.checkLegacyResponse (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: Protractor.waitForAngular() - Locator: By(xpath, //*[@id='environment-info-modal']/div/div/div[3]/button)
at Driver.schedule (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at ProtractorBrowser.executeAsyncScript_ (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\protractor\built\browser.js:425:28)
at angularAppRoot.then (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\protractor\built\browser.js:456:33)
at ManagedPromise.invokeCallback_ (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\selenium-webdriver\lib\promise.js:668:7
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: Run afterAll in control flow
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
From asynchronous test:
Error
at Suite.<anonymous> (C:\gitlab\edamis\EDAMIS-portal\src\main\front\e2e\all-access.e2e-spec.ts:39:5)
at Object.<anonymous> (C:\gitlab\edamis\EDAMIS-portal\src\main\front\e2e\all-access.e2e-spec.ts:17:1)
at Module._compile (module.js:643:30)
at Module.m._compile (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\ts-node\src\index.ts:422:23)
at Module._extensions..js (module.js:654:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\ts-node\src\index.ts:425:12)
at Module.load (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\coffeescript\lib\coffee-script\register.js:45:36)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Array.forEach (<anonymous>)
at Function.promise (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:682:9)
at _fulfilled (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:796:13)
at C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:556:49
at runSingle (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:137:13)
at flush (C:\gitlab\edamis\EDAMIS-portal\src\main\front\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)

HTML代码是这个

<div _ngcontent-c6="" class="drag-n-drop-container" id="drop-zone" ng2filedrop="" ng-reflect-queue="[object Object]" xpath="1"><p _ngcontent-c6="">Drop files here</p><p _ngcontent-c6="">or</p><p _ngcontent-c6=""><label _ngcontent-c6="" class="btn btn-sm btn-default btn-file" for="file-upload"> Select files </label><input _ngcontent-c6="" id="file-upload" multiple="" ng2fileselect="" type="file" ng-reflect-queue="[object Object]" style=""></p></div>

操作系统:Windows 10我的 Protractor 版本是 5.3.0 Angular 版本是7.1.3

我也验证了文件的文件夹,但是没问题

你有什么想法,可能是什么问题?请帮助我!!!!

最佳答案

我找到了解决方案

    var fileToUpload = './resources/1.txt',
absolutePath = path.resolve(__dirname, fileToUpload);

browser.sleep(5000);
browser.ignoreSynchronization = true;
element(by.id('file-upload')).sendKeys(absolutePath);

关于angular - 加载文件 Protractor 失败 - 失败 : script timeout: result was not received in 11 seconds,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54712899/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com