Timeout error when trying to test ionic app with selenium+protractor - selenium

Error: Angular could not be found on the page index.html : retries looking for angular exceeded
I'm getting this error after I followed the ionic tutorial for setting up protractor.
Here's my protractor-conf.js:
exports.config = {
capabilities: {
// You can use other browsers
// like firefox, phantoms, safari, IE (-_-)
'browserName': 'chrome'
},
// chromeDriver: ['./node_modules/protractor/selenium/chromedriver'],
specs: [
// We are going to make this file in a minute
'e2e/specs.js'
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
isVerbose: true,
},
allScriptsTimeout: 20000,
onPrepare: function(){
browser.driver.get('http://localhost:3000');
}
};
I noticed in another tutorial, it had me give it a pointer to the selenium server. Maybe that's the problem?
I added the chromeDriver line in there, but it broke it even more, so I commented it out
Also, I have ionic serve up and running like the tutorial says.

Solved by adding the ionic server address localhost:8100/app to the baseURL property in protractor configuration file

Related

Browserstack - Not able to use browser.get on mobile devices

So I am trying to do something very simple yet so hard to understand for me the reason why its not working.
I am using browserstack combined with protractor and it is as simple as adding this to the config:
let SpecReporter = require('mochawesome').SpecReporter;
exports.config = {
baseUrl: 'http://testing.net/',
"browserstackUser": "test",
"browserstackKey": "1234",
multiCapabilities: [
{
os_version: "9.0",
device: "Samsung Galaxy S10 Plus",
real_mobile: false,
browserName: "Android",
project: "Selenium-Test",
build: "Build 1337",
name: "Mobile - Happy Flow"
}
],
mochaOpts: {
reporter: "mochawesome",
timeout: 60000,
},
suites: {
all: 'pages/*.js',
},
framework: 'mocha',
};
and whenever I run the code it starts by:
describe('FIRST TEST', function () {
var EC = protractor.ExpectedConditions;
browser.waitForAngularEnabled(false);
browser.manage().window().maximize();
brwoser.get('http://testing.net/');
}
and it seems to be stuck through here. I was watching the live demo of what is happening and it seems like it doesn't want to open the URL even thought I do have the link which is odd. and I am not sure if I am doing anything wrong for mobile version but yeah.
The problem is I can't open any URL for the phones but works well on desktop
Can you remove browser.manage().window().maximize(); for the mobile code
You can review a sample provided by BrowserStack in the link: https://github.com/browserstack/protractor-browserstack and execute the tests on similar lines

Appium/Protractor - Cordova app - When I try to run simple test I get following error - Failed to get sockets matching: #webview_devtools_remote_

I'm trying to run a simple test on my hybrid app with Appium + Protractor and I am unable to since I am getting following error:
Failed to get sockets matching: #webview_devtools_remote_.*15239
I am using Ubuntu, and on it I have set up Appium and Protractor, tried literally every solution I have found on the internet, could not resolve the issue.
Only thing that would "remove" the error is adding following code into capabilities:
chromeOptions: {
androidPackage: "com.android.chrome"
},
But then I only get in the app, and Appium server just gets stuck at:
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":{"chromeOption {"androidPackage":"com.android.chrome","androidUseRunningApp":true,"androidDeviceSerial":"1cdc4ed10c027ece"}}}
It won't start the spec file at all.
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
seleniumAddress: 'http://localhost:4723/wd/hub',
allScriptsTimeout: 50976,
specs: [
'test.js'
],
capabilities: {
platformName: 'Android',
platformVersion: '8.0.0',
deviceName: 'Galaxy S9',
app: 'path_to_app',
autoWebview: true,
browserName: '',
appPackage: 'app_package_name',
newCommandTimeout: '140',
chromeOptions: {
androidPackage: "com.android.chrome"
}
},
onPrepare: function () {
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
},
framework: 'jasmine',
jasmineNodeOpts: {
print: function () {}, //remove protractor dot reporter
defaultTimeoutInterval: 100000
}
}
It seems to be a common appium problem.
Issue from github: https://github.com/appium/python-client/issues/255
Fix:
See here: https://github.com/blutter/appium-crosswalk-fix
This also happens if you want to switch to a web browser on the mobile phone, while you have already instanciated an appium on a mobile app.
To avoid having this exception, such as described in
https://github.com/appium/appium/issues/11189, [Chromedriver] Error: Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. (Original error: unknown error: Failed to get sockets matching: #webview_devtools_remote_.*24811 ,
before trying to switch to your web browser on the mobile phone just, reinstantiate the appium forcefully to web like below. Appium will pilot the appp then be forced and
switch cleanly to the web browser without complaining anymore :
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome"); // or other browsers
desiredCapabilities.setCapability("noReset", true );
try
{
URL url = new URL("http://127.0.0.1:4723/wd/hub");
AppiumDriver driver = new AppiumDriver(url, desiredCapabilities);
}
catch (Exception e )
{
}
I got rid of a similar error after changing the default browser of the mobie device to Chrome from Samsung. Also updated the chromedriver version on laptop running appium server to match the version of Chrome version running on mobile. And appium was started with appium --chromedriver-executable=/usr/local/bin/chromedriver.
Also had setWebContentsDebuggingEnabled=true in desired_capabilities.

Protractor test broke after enabling local SSL certificate

My Protractor and Typescript based test code is broken, after team install local SSL certificate on the server. Though it able to load the provided URL on browser but still throwing error " Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application."
Based on Protractor-invalid-ssl link have added below snippet in my config but still it throw same error. Have also tried with other options:
acceptSslCerts: true, trustAllSSLCertificates: true, acceptInsecureCerts:true,
ACCEPT_SSL_CERTS:true
But none of the option/arguments work.
/**Browser capabilities */
capabilities: {
browserName: 'chrome',
marionette : true,
acceptInsecureCerts : true
},
Have also tried with firefox still getting same error.
Using Node v8.11.3, chrome 69.0, Protractor 5.4.0, Jasmine 2
When using browser 'chrome', do not set marionette propertie its firefox specific.
You can try with the following capability for chrome:
capabilities: {
browserName: 'chrome',
trustAllSSLCertificates: true,
acceptInsecureCerts: true,
ACCEPT_SSL_CERTS: true,
},

Cannot run e2e tests with protractor: cannot resolve path?

I can’t seem to run my e2e tests with protractor. Before I begin here is some background info:
Node: 7.7.4
NPM: 4.1.2.
Angular: 4.1.0
Protractor: 5.1.2
After I ran npm install protractor, I installed and updated web driver and got an update for IE. After I wrote my first test—a simple test to grab the text of the h1 tag on my login page—I attempted to run protractor and got an error: Error: Cannot find module ‘ts-node’ so I went and installed that. Now when I rerun protractor I get a mysterious error I cannot resolve: the specified path does not exist: e2e/tsconfig.e2e.json. What does this mean? My protractor conf.js file looks like this:
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [ //path of specs is relative to location of protractor.conf.js file.
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
//'browserName': 'chrome' ---default
'browserName': 'internet explorer',
'platform': 'ANY',
'version': '11'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
I tried fooling around with the path under the project parameter, but no luck with that resolving the issue. And my project structure is set up likes this:
Any suggestions? Should I post this as an issue on github? To ts-node? Or protractor? Any suggestions would be appreciated. Please let me know if you need additional context too.
It means it's trying to find tsconfig.e2e.json (the typescript config file for your 'e2e' project) and can't. This part of the config shows the path it's looking for:
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
But it's clear from your directory structure that it isn't there. Given the path to your spec files, I would imagine the line should read:
project: './e2e/tsconfig.e2e.json'
Looking at your project structure though, it could well be:
project: './app/e2e/tsconfig.e2e.json'
In which case, the path to your spec files will probably need changing to match.

Error when running Selenium Server via Nightwatch

I'm attempting to run a simple test script. But I receive the following error:
I have my nightwatch config file setup as so:
nightwatch.conf.js
module.exports = {
"src_folders": [
"tests"// Where you are storing your Nightwatch e2e/UAT tests
],
"output_folder": "./reports", // reports (test outcome) output by nightwatch
"selenium": {
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": "./node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar",
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": { "webdriver.chrome.driver" : "./node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver"
}
},
"test_settings": {
"default": {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
},
"globals": {
"waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
},
"desiredCapabilities": { // use Chrome as the default browser for tests
"browserName": "chrome"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true // set to false to test progressive enhancement
}
}
}
}
guinea-pig.js
module.exports = { // addapted from: https://git.io/vodU0
'Guinea Pig Assert Title': function(browser) {
browser
.url('https://saucelabs.com/test/guinea-pig')
.waitForElementVisible('body')
.assert.title('I am a page title - Sauce Labs')
.saveScreenshot('ginea-pig-test.png')
.end();
}
};
The server path and chromedriver path are accurate and the most recent copy. I also have the latest version of chrome installed. Can someone please help me understand what could be the problem? Thanks!
Edit: I've also restarted the whole computer, same issue.
Try using the latest version of the Selenium standalone server v.3.0.1
If that doesn't work, then you can upgrade your chromedriver to the latest version and test. You can find the different versions here:
https://chromedriver.storage.googleapis.com/index.html
Also make sure you are using the most recent version of Nightwatch v0.9.9 and update it in you package.json file.
It is written very clear , your chrome version is lower than what chromedriver needs, just update your chrome to the latest version