How to read file that has been downloaded on selenium grid for protractor e2e tests? - protractor

Here is my capabilities settings :
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox'],
prefs: {
'download': {
prompt_for_download: false,
directory_upgrade: true,
default_directory: process.cwd()
}
}
}
}
and it fails when I am trying to read this file
also I tried adding '/temp to the default directory please advise

Related

"before each" hook: codeceptjs error message

im using codeceptjs using protractor helper, and i tried to wtite simple code
and to run this command"npm run codeceptjs"
and i faced this error "× "before each" hook: codeceptjs.before for "test something" in 285ms"
here is my code on this file "test_test.js"
Feature('My First Test');
Scenario('test something', ({ I }) => {
I.amOnPage('/');
I.see('GitHub');
});
here package.json
{
"name": "codeceptjs-tests",
"version": "0.1.0",
"private": true,
"scripts": {
"codeceptjs": "codeceptjs run --steps",
"codeceptjs:headless": "HEADLESS=true codeceptjs run --steps",
"codeceptjs:ui": "codecept-ui --app",
"codeceptjs:demo": "codeceptjs run --steps -c node_modules/#codeceptjs/examples",
"codeceptjs:demo:headless": "HEADLESS=true codeceptjs run --steps -c
node_modules/#codeceptjs/examples",
"codeceptjs:demo:ui": "codecept-ui --app -c node_modules/#codeceptjs/examples"
},
"devDependencies": {
"#codeceptjs/configure": "^0.8.0",
"#codeceptjs/examples": "^1.2.1",
"#codeceptjs/ui": "^0.4.6",
"codeceptjs": "^3.0.0",
"playwright": "^1.19.2",
"protractor": "^5.3.0"
}
}
here codecept.conf.js file
const { setHeadlessWhen } = require('#codeceptjs/configure');
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
Protractor: {
url: 'http://www.github.com',
driver: 'hosted',
browser: 'chrome',
rootElement: 'body',
angular: false
}
},
include: {
I: './steps_file.js'
},
bootstrap: null,
mocha: {},
name: 'Task1',
plugins: {
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
tryTo: {
enabled: true
},
screenshotOnFail: {
enabled: true
}
}
}
how could i fix the issue?
Error seems to be related to the selenium server. You can see details on https://github.com/codeceptjs/CodeceptJS/issues/2634
Please follow the steps on codecept website for project setup
https://codecept.io/angular/#setting-up-codeceptjs-with-protractor

Protractor multiCapabilities on single browser

I am trying to write a single Protractor config file to test a website on desktop/laptop, Android, and iPhone cases.
The following works:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: process.env.JHI_E2E_HEADLESS
? ['--headless', '--disable-gpu', '--window-size=800,600']
: ['--disable-gpu', '--window-size=800,600'],
},
},
The following also works:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: process.env.JHI_E2E_HEADLESS
? ['--headless', '--disable-gpu', '--window-size=800,600']
: ['--disable-gpu', '--window-size=800,600'],
mobileEmulation: {
deviceName: 'iPhone 6/7/8 Plus'
},
},
},
However, the following fails with the error
[chrome #01] [16:06:44] I/direct - Using ChromeDriver directly...
[chrome #01] [16:06:45] I/runnerCli - Unexpected token {
multiCapabilities: [
{
name: 'ChromeDesktop',
browserName: 'chrome',
chromeOptions: {
args: process.env.JHI_E2E_HEADLESS
? ['--headless', '--disable-gpu', '--window-size=800,600']
: ['--disable-gpu', '--window-size=800,600'],
},
},
{
name: 'ChromeAndroid',
browserName: 'chrome',
chromeOptions: {
args: process.env.JHI_E2E_HEADLESS
? ['--headless', '--disable-gpu', '--window-size=360,640']
: ['--disable-gpu', '--window-size=360,640'],
mobileEmulation: {
deviceName: 'Galaxy S5'
},
},
},
],
Can anyone kindly explain what I am doing wrong?
Adding below in protractor conf should work -
onPrepare: function () { require('ts-node').register({ project: 'e2e' }); }
Link To Related GitHub Issue with Accepted Solution -> It has the details why onPrepare should be used instead of default beforeLaunch for enabling multiple capabilities for browsers.

Protractor tests Azure Pipelines - using Internet Explorer

We have a big set of automated tests using Protractor/Jasmine which work like a dream on Azure Pipelines. However, so far we've only used Chrome as the browser.
Now i have to run the same tests using Internet Explorer (11) but am getting no joy at all!!
Here's a part of my conf.js file that deals with the browser:
var HtmlReporter = require('protractor-beautiful-reporter');
var {SpecReporter} = require("jasmine-spec-reporter");
var jasmineReporters = require("jasmine-reporters");
exports.config = {
//seleniumAddress: `http://localhost:4444/wd/hub`,
framework: "jasmine2",
specs: ['specs/secureTrading/01_SecureTrading.js',
'specs/secureTrading/02_ST_Payments.js'
],
getPageTimeout: 40000,
allScriptsTimeout: 60000,
capabilities: {
'browserName': 'internet explorer',
'ignoreProtectedModeSettings': true,
'platform': 'ANY',
'version': '11',
args: ['--silent', '--no-sandbox', '--test-type=browser', '--lang=US', '--start-maximized'], //,'--headless', '--disable-gpu'
prefs: {
'download': {
'prompt_for_download': false,
'directory_upgrade': true,
'extensions_to_open': '',
'default_directory': process.cwd() + '/downloads/'
},
}
},
localSeleniumStandaloneOpts: {
jvmArgs: [
'-Dwebdriver.ie.driver=node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer3.14.0.exe'
]
},
directConnect: false,
seleniumArgs: ['-Dwebdriver.ie.driver=node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer3.14.0.exe'],
ignoreUncaughtExceptions: true,
onPrepare: function() {
Having looked at other postings, I've tried removing // from seleniumAddress:http://localhost:4444/wd/hub,` still errors, Changing DirectConnect makes no difference.
With the settings as above, this is the error message.
Any advice please?
Thanks
Additional Logs as per comment below.
Local:

Group all tests and display in browserstack

I am running my protractor tests on browserstack and noticed that the tests I run are marked as separate entries. I want to group them all into a single build.
I have added build capability to my protractor config file. But it doesn't seem to help.
Attaching my protractor configuration field. Appreciate your help.
Thanks
exports.config = {
specs: [
'./src/**/*.e2e-spec.ts'
],
browserstackUser: xx,
browserstackKey: xxx,
multiCapabilities: [{
browserName: 'chrome',
os: 'Windows',
os_version: '10',
'browswestack.debug': true,
project: 'protractor'
}, {
os: 'OS X',
os_version: 'High Sierra',
browserName: 'Safari',
'browswestack.debug': true,
project: 'protractor'
}],
build_number: 'local',
maxInstances: 2,
SELENIUM_PROMISE_MANAGER: false,
directConnect: false,
connectionRetryCount: 3,
connectionRetryTimeout: 90000,
baseUrl: 'http://localhost:4200',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: _.noop
},
onPrepare: () => {
tsNode.register({
project: path.join(__dirname, './tsconfig.e2e.json')
});
let reporter = new SpecReporter();
jasmine.getEnv().addReporter(reporter);
}
};
EDIT : I fixed the problem. I was using build_number instead of build.
However , when I run the tests I noticed that the tests are getting appended. For instance if I run 5 tests , I could only see the last test as executed in browserstack. How should I fix this ?
Open a session on Automate Dashboard and under 'Input Capabilities', check if 'build' is visible.

Protractor - Cucumber config query

My query is how config.js will be called when we say for example.. "npm run test" this will run tests as per the configuration defined in config.js
example my package.json contains
"scripts" : {
"test" : "Env=ST CukeTags=regression testrunner -s functional"
}
another query I had is, where can I find the details about how these config files, hooks file will be interrelated? how will these be called during the protractor tests running?
You should set the test script in your package.json
That test script will tell the command to run protractor giving the path of config file.
"scripts":{"test": "protractor typeScript/config/config.js"}
Here the test command will run protractor with the config file inside typescript/config folder.
Sample config file for protractor and cucumber
import * as path from "path";
import { browser, Config } from "protractor";
import { Reporter } from "../support/reporter";
const jsonReports = process.cwd() + "/reports/json";
export const config: Config = {
seleniumAddress: "http://127.0.0.1:4444/wd/hub",
SELENIUM_PROMISE_MANAGER: false,
baseUrl: "https://www.google.com",
capabilities: {
browserName: "chrome",
},
framework: "custom",
frameworkPath: require.resolve("protractor-cucumber-framework"),
specs: [
"../../features/*.feature",
],
onPrepare: () => {
browser.ignoreSynchronization = true;
browser.manage().window().maximize();
Reporter.createDirectory(jsonReports);
},
cucumberOpts: {
compiler: "ts:ts-node/register",
format: "json:./reports/json/cucumber_report.json",
require: ["../../typeScript/stepdefinitions/*.js", "../../typeScript/support/*.js"],
strict: true,
tags: "#CucumberScenario or #ProtractorScenario or #TypeScriptScenario or #OutlineScenario",
},
onComplete: () => {
Reporter.createHTMLReport();
},
};