How to debug a uiveri5 test? - uiveri5

I am following the docs word by word, i.e. start my Basic.spec.js with uiveri5 --debug (using default local browser) and have a debugger; statement within some it() in the test code. Yet the tests runs thru, passing that test, and will not stop in any way in any debugger.
conf.js:
exports.config = {
profile: "integration",
specs: "./*spec.js",
baseUrl: 'http://localhost:2027/...'
};
Basic.spec.js:
describe('Basic', function () {
it('1 should load the app', function() {
expect(browser.getTitle()).toBe('Hurz,');
});
it('2 should open detail screen', function() {
debugger;
element(by.control({viewName: ..., id: ...})).click();
let name = element(by.control({viewName: ..., id: ...}));
expect(name.getText()).toBe("");
});
})
Console:
$ uiveri5 --debug
Starting uiveri5 with node arguments --inspect
Debugger listening on ws://127.0.0.1:9229/2584e64b-5d72-41f1-99ea-a51c8f073245
For help, see: https://nodejs.org/en/docs/inspector
INFO: #ui5/uiveri5 v1.41.2
INFO: Resolving specs
INFO: Check for latest major version of: chromedriver
(node:55071) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
INFO: Found latest major version of chromedriver: 79
INFO: Check for latest version of: chromedriver
INFO: Found latest version of chromedriver: 79.0.3945.36
INFO: Found correct binary locally: /usr/local/lib/node_modules/#ui5/uiveri5/selenium/chromedriver-79.0.3945.36
INFO: Executing 1 specs
[15:34:04] I/launcher - Running 1 instances of WebDriver
INFO: Suite started: Basic
INFO: Spec started: 1 should load the app
INFO: Opening: http://localhost:2027/...
INFO: UI5 Timestamp: 201910301504
INFO: Spec finished: 1 should load the app with status: PASSED
INFO: Spec started: 2 should open detail screen
INFO: Spec finished: 2 should open detail screen with status: PASSED
...
What am I missing?

go to chrome://inspect/#devices
click open dedicated DevTools for Node
and run uiveri5 --debug or --inspect
more reference is in the documentation here (UIveri5) and here (Node)

Related

How to launch protractor tests from remote jenkins?

I am unable to launch my protractor test from remote jenkins.
I am able to launch the test if the jenkins is installed in my local.
I am not sure if it is because of the direct connect. i also tried to launch the protractor test through selenium webdriver but couldnt make it. please help on this.
The error i am getting is
*[16:06:14] I/launcher - Running 1 instances of WebDriver
[16:06:14] I/direct - Using ChromeDriver directly...
[16:16:15] E/launcher - session not created
from timeout: Timed out receiving message from renderer: 600.000
(Session info: chrome=88.0.4324.104)
(Driver info: chromedriver=88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324#{#1784}),platform=Windows NT 10.0.17763 x86_64)
[16:16:15] E/launcher - SessionNotCreatedError: session not created
from timeout: Timed out receiving message from renderer: 600.000
(Session info: chrome=88.0.4324.104)
(Driver info: chromedriver=88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324#{#1784}),platform=Windows NT 10.0.17763 x86_64)
at Object.checkLegacyResponse (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\selenium-webdriver\lib\http.js:509:13)
at C:\home\Administrator\workspace\BlueNet_Automation\node_modules\selenium-webdriver\lib\http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.createSession()
at Function.createSession (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at Function.createSession (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\selenium-webdriver\chrome.js:761:15)
at Direct.getNewDriver (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\protractor\built\driverProviders\direct.js:77:33)
at Runner.createBrowser (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\protractor\built\runner.js:195:43)
at C:\home\Administrator\workspace\BlueNet_Automation\node_modules\protractor\built\runner.js:339:29
at _fulfilled (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\q\q.js:834:54)
at C:\home\Administrator\workspace\BlueNet_Automation\node_modules\q\q.js:863:30
at Promise.promise.promiseDispatch (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\q\q.js:796:13)
at C:\home\Administrator\workspace\BlueNet_Automation\node_modules\q\q.js:556:49
at runSingle (C:\home\Administrator\workspace\BlueNet_Automation\node_modules\q\q.js:137:13)
[16:16:15] E/launcher - Process exited with error code 199
npm ERR! Test failed. See above for more details.
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE*
my config.ts file is
*export let config: Config = {
// The address of a running selenium server.
//seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect:true,
framework:'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
//allScriptsTimeout: 30000,
// Capabilities to be passed to the webdriver instance.
capabilities: {
browserName: 'chrome'
},
// Spec patterns are relative to the configuration file location passed
// to protractor (in this example conf.js).
// They may include glob patterns.
specs: ['../features/MasterEdit.feature'],
cucumberOpts: {
// require step definitions
//tags:"#SmokeTesting",
format:'json:./cucumberreport.json',
require: [
'./stepDefinitions/*.js', // accepts a glob,
]
},
onComplete: () =>{
var options = {
theme: 'bootstrap',
jsonFile: './cucumberreport.json',
output: './cucumber_report.html',
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
"App Version":"0.3.2",
"Test Environment": "STAGING",
"Browser": "Chrome 54.0.2840.98",
"Platform": "Windows 10",
"Parallel": "Scenarios",
"Executed": "Remote"
}
};
reporter.generate(options);
}*

Xvfb and Protractor produce Timeouts

I want to run protractor tests on a webserver integration platform without gui based on redhat linux. The tests will be executed whenever the webserver software will be deployed. I use firefox and geckodriver.
The call chain is
protractor calls
firefox on
Xvfb calls
(local) Webserver
and backwards to the caller.
I get Jasmine timeouts when starting Protractor with Xvfb.
My environment:
node: v12.14.1
npm: 6.14.2
Xvfb: ?, installed, callable
xvfb-run: ?, installed, callable
My start scripts:
Selenium:
java -jar -Dwebdriver.chrome.driver=/pathx/geckodriver-v0.26.0 /pathy/selenium-server-standalone-3.141.59.jar &
This is essentially what 'webdriver-manager start' does, but I cannot need the update ahead.
Xvfb:
xvfb-run --auto-servernum --server-args='-screen 0 1920x1200x24' -e xvfb.err firefox &
Protractor:
DISPLAY=:99 protractor --verbose --troubleshoot --logLevel=DEBUG protractor.conf.js
All I get is
[15:00:59] D/launcher - Running with --troubleshoot
[15:00:59] D/launcher - Protractor version: 5.4.3
[15:00:59] D/launcher - Your base url for tests is undefined
[15:00:59] I/launcher - Running 1 instances of WebDriver
[15:00:59] I/direct - Using FirefoxDriver directly...
[15:01:00] D/runner - WebDriver session successfully started with capabilities C apabilities {
map_: Map {
'acceptInsecureCerts' => false,
'browserName' => 'firefox',
'browserVersion' => '60.9.0',
'moz:accessibilityChecks' => false,
'moz:geckodriverVersion' => '0.26.0',
'moz:headless' => false,
'moz:processID' => 32246,
'moz:profile' => '/tmp/rust_mozprofileAz14ww',
'moz:useNonSpecCompliantPointerOrigin' => false,
'moz:webdriverClick' => true,
'pageLoadStrategy' => 'normal',
'platformName' => 'linux',
'platformVersion' => '3.10.0-957.el7.x86_64',
'rotatable' => false,
'timeouts' => { implicit: 0, pageLoad: 300000, script: 30000 }
}
}
[15:01:00] D/runner - Running with spec files /home/xgadvls/az-uss/frontend/e2e/ src/specs/login/login-spec.ts,/home/xgadvls/az-uss/frontend/e2e/src/specs/logout /logout-spec.ts
Started
undefined
F(node:32231) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
Failures:
1) Anmeldung Anmeldedate werden eingegeben
Message:
Failed: WebDriverError
Stack:
Error: Failed: WebDriverError
at /home/xgadvls/az-uss/node_modules/jasminewd2/index.js:64:48
...
How can I get a webdriver error when I haven't got it in my call chain?! What am I doing wrong? Can anybody help?
The problem was caused by an invalid certificate.
My way to the solution may be interesting.
I renamed the geckodriver-v0.26.0 (or so) to geckodriver.bin.
I made a script with the original geckodriver name and called in that script the bin version with -vv argument (very verbose) and redirected the output into a file (>myfile). It is important to pass all parameters ($#).
The next test informed me in the log file about the invalid certificate. This can be fixed by a parameter AcceptInsecureCerts for firefox. (I guess chrome as well)
Here we go.
I hope this helps anybody.

How to run successfully Protractor e2e test in Cloud Builders?

I'm setting up CI for our project that is in Angular. We are using Google Cloud Platform's Cloud Builder for CI. Everything is going smoothly, we can setup the environment, install packages via npm, build the project using angular-cli and deploy. But the problem is that our test cases (e2e) in Protractor keeps getting an error. What are we missing here?
This is for the Continuous Integration using Google Cloud Builders, we are running the protractor in headless mode, and using the puppeteer's chromium as the chrome's binary path
This is my protractor.conf.js
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath()
exports.config = {
allScriptsTimeout: 1000000,
specs: [
'./e2e/*.e2e-spec.ts',
'../e2e/*.e2e-spec.ts'
],
capabilities: {
// browserName: 'chrome',
browserName: 'chrome',
chromeOptions: {
binary: process.env.CHROME_BIN,
args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', '--disable-setuid-sandbox']
}
},
// seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
// ignoreUncaughtExceptions: true,
directConnect: true,
},
};
This is the error we are getting in cloud builders
[11:24:12] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-1033-gcp x86_64)
[11:24:12] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Selenium GeckoDriver with Protractor: "Failed: Timed out"

My automation test suite uses Selenium WebDriver with Protractor and Jasmine to run against a variety of browsers. When using GeckoDriver to run the tests on Firefox, I am intermittently getting an error message that just says "Failed: Timed out":
. ✓ WHEN I visit the favorites page
. ✓ THEN it should say I havent added anything
F ✗ WHEN I open the inspirations page
- Failed: Timed out
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'admins-MacBook-Pro-3.local', ip: 'fe80:0:0:0:10a7:9b8d:6ff5:f46%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144'
Driver info: driver.version: unknown
F ✗ AND I click on an inspiration preview pane to open an inspiration
I have tried padding it with hard-coded sleep on either side, and I've searched for other errors, but everything else I can find in regards to Protractor timeouts is for other errors that have some kind of a description about what is actually timing out.
Has anyone seen JUST the message "Failed: Timed out" here who can help determine what might be timing out?
As requested, here is the gulp task that kicks off my protractor:
gulp.task('test-frontend-firefox', 'Run feature tests locally', function() {
gulp.src(['test/feature/**/*.spec.js'])
.pipe(protractor({
configFile: __dirname + '/../test/protractor_local_ff.conf.js',
args: ['--baseUrl', 'http://localhost:9099'],
}));
});
And here is protractor_local_ff.conf.js as referenced by the gulp task:
var private_config = require('./private.conf.js');
var golden_config = require('./golden.conf.js');
exports.config = {
params: {
private: private_config,
golden: golden_config,
localhost: true
},
onPrepare: function(){
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
},
framework: 'jasmine2',
// seleniumAddress: 'http://hub-cloud.browserstack.com/wd/hub',
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'firefox'
}
};
As you can see, it's set up to be able to run against the hosted app in either browserstack or on my localhost, but the error gets thrown intermittently in either environment.

Chrome not firing by default through the webdriver-manager

I'm a newbie in e2e tests with protractor and I've recently encountered an issue. When I try to run my test (which is basically the same one I found on the official protractor website), the server starts by using Firefox as a default browser. As I read, chrome supposed to be the one used by default.
16:17:24.345 INFO - Executing: [new session: Capabilities [{count=1, browserName=firefox}]])
16:17:24.345 INFO - Creating a new session for Capabilities [{count=1, browserName=firefox}]
16:17:27.305 INFO - Done: [new session: Capabilities [{count=1, browserName=firefox}]]
Due to the Firefox issue #1734, the test fails all the time
Failures:
1) angularjs homepage todo list should add a todo
Message:
timeout: timed out after 36000 msec waiting for spec to complete
Stacktrace:
undefined
Finished in 36.777 seconds
1 test, 1 assertion, 1 failure
So I added chrome as another browser to use into the configuration file
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
browserName: 'chrome'
},
specs: ['todo-spec.js'],
framework: 'jasmine'
};
Here's the test
todo-spec.js
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('http://angularjs.org');
element(by.model('todoText')).sendKeys('write a protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write a protractor test');
});
});
But it still does not work. What am I doing wrong here?
Thanks for your help!