protractor cannot find environments/environment - intellij-idea

I am running my spec from IntelliJ by clicking on the green triangle in the left gutter. It seems it starts protractor. My test cases don't run unfortunately. The Chrome window opens for a moment only. I see the following error on the IntelliJ screen
"C:\Program Files\nodejs\node.exe" "C:...\bin\protractor" "C:\...\protractor-intellij\lib\protractor-intellij-config.js" "--intellijOriginalConfigFile=C:...\web\ui\protractor.conf.js" --disableChecks --specs "C:\...\ui\src\app\nav-component\nav-component.component.spec.ts" "--grep=^NavComponentComponent "
(node:22316) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[17:25:17] I/launcher - Running 1 instances of WebDriver
[17:25:17] I/direct - Using ChromeDriver directly...
(node:22316) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[17:25:21] E/launcher - Error: Error: Cannot find module 'environments/environment'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
...
at Object.<anonymous> (C:\Users\RSI\Documents\manu data\Documents\manu\codingjedi\code_related\code\frontend\web\ui\src\app\web-to-backend-interface.service.ts:2:1)
[17:25:21] E/launcher - Process exited with error code 100
Process finished with exit code 4
Why protractor can't find the file?
The tests work fine if I use ng test --source-map=false. The issue arises when I use protractor. Even though I am using protractor, I am not running e-2-e tests.

Related

Mocha, Electron: Errors in testing

I was testing my electron app with mocha and got this error several times (and I'm still getting it!). Every time I run the program it returns with the error
> Executing task: npm run test <
> forte#1.0.0 test PATH TO PROJECT
> mocha ./tests/test.js
0 passing (3ms)
Test failed Failed to create session.
unknown error: Chrome failed to start: was killed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location \node_modules\spectron\lib\launcher.bat is no longer running, so ChromeDriver is
assuming that Chrome has crashed.)
Just in case this is important, the part which says (The process started from chrome location \node_modules... actually had the whole path, not just that.
In my test.js file I have the code from the spectron home page, which you can view here. What is wrong with the test files?

Selenium Headless Firefox - Very Slow

I am trying to fetch some web data using Selenium to run Firefox in headless mode in a Python3 script. I am running the script on Debian.
The code works fine, but is very very slow. Half a minute to get the title of the webpage. I need to use this in a production environment and it won't work if it's that slow. I am new to Selenium so it may be a basic mistake I am making...
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
import time
from decimal import Decimal
start_time = time.time()
fireFoxOptions = webdriver.FirefoxOptions()
fireFoxOptions.set_headless()
browser = webdriver.Firefox(firefox_options=fireFoxOptions)
fetchUrl = "https://www.amazon.com/CakCity-Military-Waterproof-Luminous-Stopwatch/dp/B018HTGSN8/ref=sxin_1_ac_d_rm?ac_md=0-0-d2F0Y2g%3D-ac_d_rm&keywords=watch&pd_rd_i=B018HTGSN8&pd_rd_r=ad451c0c-abfe-4436-bee4-d11f9e1dbb1e&pd_rd_w=J9Zl5&pd_rd_wg=AqMuw&pf_rd_p=ed481207-4bea-4e19-bbad-73ed40fdc292&pf_rd_r=A7B9299YFYD1G0JZ81YH&psc=1&qid=1573502062"
browser.get( fetchUrl )
print ( browser.title )
executionTime = round(time.time() - start_time, 2)
print( "- execution time [" + str( executionTime ) + "]" )
browser.close()
browser.quit()
Execution time varies from 20s to 30s
Debian 9.4 (Stretch)
Firefox 70.0.1
Geckodriver 0.26.0
Selenium 3.141.0
Python 3.5.3
I have tried limiting the libraries I import, and it has no change.
I have tested several different websites, such as just google.com, and the response time is the same. I can load these sites within seconds manually through any browser, so I would think headless mode would be faster. The script does not throw any errors.
Gecko log
1573530232430 mozrunner::runner
INFO Running command: "/usr/bin/firefox" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileKfYEBK"
*** You are running in headless mode.
1573530233337 addons.webextension.screenshots#mozilla.org
WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1573530233337
addons.webextension.screenshots#mozilla.org
WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: telemetry
1573530233338
addons.webextension.screenshots#mozilla.org
WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1573530233338
addons.webextension.screenshots#mozilla.org
WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: about:reader*
1573530237793 Marionette
INFO Listening on port 36801
1573530237852 Marionette
WARN TLS certificate errors will be ignored for this session
[Parent 1707, Gecko_IOThread]
WARNING: pipe error: Broken pipe: file /builds/worker/workspace/build/src/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 728
1573530254051
Marionette
INFO Stopped listening on port 36801
I researched all of the warnings listed above with mixed ideas on solutions.
The "pipe error" does not always show up in the logs, seems random. Also unusual as it says chromium, but I am using Firefox...
I am unclear on the permission errors even after reading up on them, some say to just disregard them as not important.
Any suggestions?
Thanks

Unspecified Protractor error at the end of a test run

I have upgraded to Protractor 6.0.0 and Jasmine 3.3.1, and had to redo all my tests to run asynchronously.
When my Protractor test finishes running, I have an unexplained error at the end. No tests fail, but the process seems to abort irregularly. I am running against Chrome 73 in the latest webdriver, where I had to specifically downgrade to Chrome 73 webdriver because 74 is still in Beta.
Here is a snapshot of a test run:
Test suite 1 Tests
√ should check first thing
√ should check second thing
√ should display another thing
Executed 3 of 94 specs INCOMPLETE (89 SKIPPED).
C:\Users\Joon\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3190
throw arguments[0];
^
NoSuchSessionError: invalid session id (Driver info:
chromedriver=73.0.3683.68
(47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT
10.0.17134 x86_64)
at Object.checkLegacyResponse (C:\Users\Joon\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:585:15)
at parseHttpResponse (C:\Users\Joon\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:533:13)
at Executor.execute (C:\Users\Joon\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:468:26)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
There is no additional error message, the only other SO post I found that had the same error message also had an additional promise rejected error afterwards.
How can I debug / troubleshoot what is causing this error?
I figured it out - there were some calls to browser.wait that did not have an await before them.
One of these was causing a synchronization error which led to that unspecified state management error at the end of the test run.
For anyone else experiencing WebDriver state errors after you upgrade from the control flow to the async flow - be sure to put await calls in front of all Protractor browser interaction calls. The one I had missed was browser.wait but it could be any other call to Protractor that causes this issue

Microsoft Edge not visiting URL when being run by Protractor script

I am building a set of Protractor scripts to evaluate the performance of a web app.
A month ago, the tests were running in both Edge and Chrome. I stepped away from the project for two weeks, and performed a Windows OS update on my return. Since then, when running the test in Microsoft Edge, I get alternating results between 1) an unknown error where the browser never even launches (I will post the cmd output from this result below), and 2) having the Edge browser open but not visiting the base URL it is supposed to (where I am getting a timeout error after being on the Edge homescreen for 10 seconds). I unfortunately did not have the opportunity to run the script before the Windows update, so I am not certain if that is the cause, but I think it is likely. The tests continue to run correctly when operating in Chrome.
I have tried reinstalling Edge's webdriver several times and have chekced its path. I would like to roll back Windows but think this would be a hassle with our IT department, so I am wondering if anyone has found a different solution to this problem?
This is the error when the browser fails to open:
\Browser Tests>protractor edge_conf
[13:32:48] I/launcher - Running 1 instances of WebDriver
[13:32:48] I/hosted - Using the selenium server at http://localhost:17556
[13:32:48] E/launcher - Unknown error
[13:32:48] E/launcher - WebDriverError: Unknown error
at WebDriverError (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5)
at Object.checkLegacyResponse (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:505:15)
at parseHttpResponse (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:777:24)
at createDriver (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:167:33)
at Builder.build (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:632:14)
at Hosted.getNewDriver (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\driverProvider.ts:60:29)
at Runner.createBrowser (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:225:39)
at q.then.then (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:391:27)
at _fulfilled (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
[13:32:48] E/launcher - Process exited with error code 199
I wound up pushing Windows to version 1703 (Build 15063.540), which was easier to get approved than rolling back.
After reinstalling the appropriate WebDriver, everything is working properly with Edge. Still unclear what was causing the problem, but this seems to have worked around it.
I'm the PM for WebDriver at Microsoft. It sounds like you need to get the proper version for your build of Windows.
You can find all the releases of WebDriver here. To see what build of Windows you have just hit [Windows Key] + [R] and type "winver".

Can I set a longer timeout for protractor to connect to selenium driver?

Running my protractor tests remotely (jenkins) leads to timeout error sometimes. That is not deterministic.
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
[launcher] Process exited with error code 1
/opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1761
throw error;
^
Error: Timed out waiting for the WebDriver server at http://10.97.193.53:4455/wd/hub
at Error (<anonymous>)
at onResponse (/opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:87:11)
at /opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:42:21
at /opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/http/http.js:96:5
at ClientRequest.<anonymous> (/opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:145:7)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1548:9)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:448:13)
However when I run the tests locally in my mac there is no problem and the tests run perfectly.
I have tried to start the selenium servers manually in the remote machines and I have realised that sometimes it works immediately and sometimes I have to wait up to one minute.
My question is: Is there any way to tell protractor to wait longer for the webdriver to connect?
Environment details
Machine: Red Hat 4.4.7-11
Protractor version: 1.8.0
Selenium Server Standalone: 2.45.0
You can specify it by using driver.wait function.
var webdriver = require('selenium-webdriver');
var protractor = require('protractor');
var driver = new webdriver.Builder().usingServer("seleniumAddress").build();
var browser = protractor.wrapDriver(driver);
browser.driver.wait(driver.getWindowHandle(), 5000, 'Server should start within 5 seconds');
References :
http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.wait
http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.getWindowHandle
Yes, and it should solve your issue. Use the seleniumServerStartTimeout option in your protractor.conf.js file to bump up the timeout from the default 30 seconds to something longer like 90 seconds:
exports.config = {
seleniumServerStartTimeout: 90000
};
I experienced the same issue on a CentOS 7 VM. For whatever reason the selenium server seems to take wildly different amounts of time to start up each time, and can sometimes exceed the default timeout.