Nightwatch tests to work on edge - microsoft-edge

I'm trying to get nightwatch tests to work in Microsoft edge. I'm getting an error saying connection refused. What's the right configuration to get tests to work on edge? Windows 10 edge 13

Could you post your configuration?
Make sure you have installed microsoft edge webdriver (you may download it here https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/).
You have to specify path to your edge driver using webdriver.edge.driver param, ex.
"selenium": {
"start_process": true,
"server_path": "./node_modules/file_dependencies/selenium-server-standalone.jar",
"log_path": "",
"host": "127.0.0.1",
"port": seleniumPort,
"cli_args": {
"webdriver.chrome.driver": "./node_modules/file_dependencies/chromedriver.exe",
"webdriver.ie.driver": "./node_modules/file_dependencies/IEDriverServer.exe",
"webdriver.edge.driver": "C:/Program Files (x86)/Microsoft Web Driver/MicrosoftWebDriver.exe",
"webdriver.gecko.driver": "./node_modules/file_dependencies/geckodriver.exe",
"webdriver.firefox.profile": ""
}
}
and example capabilities
"edge": {
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"javascriptEnabled": true,
"acceptSslCerts": true,
"pageLoadStrategy": "eager"
}
}

Related

Issue with Docker compose and Kestrel in asp.net 6.0 app

I'm trying to run my aspnet 6.0 app using docker(Linux Container on Windows system) and having issues. it runs perfectly fine when I'm not trying to configure kestrel. But whenever i'm trying to add below code, i'm getting issue saying "This site can’t be reached localhost unexpectedly closed the connection."
builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.Listen(IPAddress.Any, 5005, options =>
{
options.Protocols = HttpProtocols.Http2;
});
serverOptions.Listen(IPAddress.Any, 7173, options =>
{
options.Protocols = HttpProtocols.Http1AndHttp2;
});
});
I'm trying to use port 5005 for GRpc purpose and 7173 to expose rest api endpoints. I'm using visual studio 2022 and generated DockerFile by adding docker support.
Here are the docker compose,compose-override yaml and container snaps.
I have also tried adding https support, but no luck.
serverOptions.Listen(IPAddress.Any, 7173, options =>
{
options.Protocols = HttpProtocols.Http1AndHttp2;
options.UseHttps("appname.pfx", "password");
});
Please Note: all of the above lines of code works great when I'm not running on docker.
I think you can configure this in appsettings.json too:
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"WebApi": {
"Url": "http://localhost:7173",
"Protocols": "Http1"
},
"gRPC": {
"Url": "http://localhost:5005",
"Protocols": "Http2"
}
}
}
}
Had to expose same ports in DockerFile as pointed out in comment by #CodingMytra

Getting "Unable to establish one or more of the specified browser connections" when running testcafe and browserstack

We are creatign a POC for running testcafe and browserstack in our jenkins.
the jenkins file starts a node instance, starts upp browserstack local, runs the tests and then closes browserstack local.
The browserstack local log indicates that it works ok, but the console states "ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure."
i can se in browserstack dashboard that the browser is started and is given an URL (example: http://127.0.0.1:44138/browser/connect/bl5rZIw) but the browser gives a "unable to connect to the page"
if i change from browserstack to a local chrome everything works. and if i run things on my local mashine it works (with browserstack.)
the networkpepole cant find any relevant blocks in the firewall. only calls to githubb.
(185.199.110.153, TCP/443,140.82.121.3, TCP/443 - BLOCKERAT,140.82.121.5, TCP/443 - BLOCKERAT, 140.82.121.6, TCP/443 - BLOCKERAT)
any ideas on what is missing or how to digg into this problem.
relevant files
------------jenkins.openshift--------------------------
node('nodejs-14') {
withRepository {
stage('Install dependencies') {
withProxy {
sh 'npm install'
}
}
stage('Test') {
withProxy {
withEnv([
"BROWSERSTACK_LOCAL_IDENTIFIER=${env.BUILD_TAG}",
"BROWSERSTACK_USERNAME=<secret :)>",
"BROWSERSTACK_ACCESS_KEY=<secret :)>"
]) {
try {
sh "src/support/linux/BrowserStackLocal --key ${env.BROWSERSTACK_ACCESS_KEY} --local-identifier ${env.BUILD_TAG} --daemon start --force-local --proxy-host rbp-openshift-registry-001.wa.loc --proxy-port 3128 --local-proxy-host <secter :)> --local-proxy-port 3128 --verbose 2 --log-file ${env.WORKSPACE}/browserstack.log"
sh "npm test"
} finally {
sh "src/support/linux/BrowserStackLocal --key ${env.BROWSERSTACK_ACCESS_KEY} --local-identifier ${env.BUILD_TAG} --daemon stop"
archiveArtifacts artifacts: 'browserstack.log'
}
}
}
}
}
}
--------------------package.json--------------------------------
{
"name": "testcafe-poc",
"version": "1.0.0",
"description": "A Proof of Concept project and template for running testcafe and browserstack. ",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/testcafe 'browserstack:chrome#93.0:Windows 10' --hostname 127.0.0.1 --proxy rbp-openshift-registry-001.wa.loc:3128 ./src/tests/test1.js"
},
"repository": {
"type": "git",
"url": "ssh://git#code.resurs.loc:7999/test/testcafe-poc.git"
},
"author": "",
"license": "ISC",
"devDependencies": {
"testcafe": "1.9.4",
"testcafe-browser-provider-browserstack": "1.13.1"
},
"dependencies": {}
}
You mentioned that everything works fine locally without Jenkins. This means that there is no error in TestCafe of BrowserStack.
Probably, the issue is in your BrowserStack Local configuration. The testcafe-browser-provider-browserstack already has its own BrowserStackLocal instance, so it's not necessary to use BrowserStackLocal from src/support/linux/BrowserStackLocal.
Please refer to the following issue to see how to setup BrowserStack proxy settings: https://github.com/DevExpress/testcafe-browser-provider-browserstack#browserstack-proxy-options.
The solution was simple and ridiculous.
We used a % in our sting for --local-identifier and that makes the BrowserStack local fail to connect.
But it does not tell you this in the logs or documentation.
So the solution is: don't use special characters in the --local-identifier.

How to provide a valid crumb in ansible jenkins_script module

I am using Ansible to check the status of several jenkins servers. The playbook that I have created checks the disk space, uptime, and jenkins version perfectly fine. However, I tried to add a task that prints out a list of the installed jenkins plugins for each server by using the jenkins_Script module and keep receiving a '403' error message.
Playbook:
- name: Obtaining a list of Jenkins Plugins
jenkins_script:
script: 'println(Jenkins.instance.pluginManager.plugins)'
url: 'http://server.com:8080/'
user: '*****'
password: '*****'
Output:
fatal: [server]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"args": null,
"force_basic_auth": true,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"script": "println(Jenkins.instance.pluginManager.plugins)",
"url": "http://server.com:8080/",
"url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"validate_certs": true
}
},
"msg": "HTTP error 403 HTTP Error 403: No valid crumb was included in the request"
}
-- I believe I have narrowed down the issue - It looks like I wasn't providing a crumb. I have since generated the crumb, but there is no 'crumb' arguement for the jenkins_script module. Does anyone know how to successfully provide a crumb?
Will gladly clarify anything stated above if needed, and any assistance is greatly appreciated.
https://github.com/ansible/ansible/pull/20207
-- if you're on ansible 2.3 the changes have already been committed all you have to do is make sure 'cross site request forgery' is enabled on the jenkins servers. (Manage jenkins > Configure Global security)

How to run asp.net mvc 4.5 in visual studio code editor?

I am looking forward to run asp.net mvc apps in vscode but it seems that the only pages that I found on google is with asp.net core which is not what I am looking. Can someone guide me with some steps, I installed some plugins like c# and msbuild. After attempt to run it. it display the following error:
"Failed to launch external program msbuild . spawn msbuild ENOENT"
The error Failed to launch external program msbuild . spawn msbuild ENOENT happens because vscode\task runner cannot find msbuild.
To run asp.net mvc 4.5 in visual studio code editor, you will need to install msbuild tools (I have installed the 2017 version) and IIS Express.
You could use vswhere to check msbuild location, in my case is C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\msbuild.exe
In vscode execute the command Tasks: Configure Task Runner and edit the content of tasks.json according the file.
{
"version": "0.1.0",
"taskSelector": "/t:",
"showOutput": "silent",
"tasks": [
{
"taskName": "build",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"windows": {
// change according your msbuild location
"command": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\msbuild.exe"
},
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
},
{
"suppressTaskName": true,
"taskName": "iisexpress",
"isShellCommand": true,
"windows": {
"command": "C:\\Program Files (x86)\\IIS Express\\iisexpress.exe"
},
"args": [
// change according your project folder and desired port
"/path:${workspaceRoot}\\MyProjectFolder",
"/port:51714"
],
// Show the iisexpress output always.
"showOutput": "always"
}
]
}
You don't need to restart your IIS on every change, you just need to build the application CTRL+SHIFT+B.
If you wan't to stop IIS use the vscode command Tasks: Terminate Running Task.
References:
https://stackoverflow.com/a/42719644/5270073
https://learn.microsoft.com/en-us/iis/extensions/using-iis-express/running-iis-express-from-the-command-line
I've created a gulpfile that handle the build for me:
It starts an IISExpress instance.
Refresh my browser on razor code change.
And automatically rebuild my application when I change C# code.
You can find the gulpfile on my project's Github
As per VS Code documentation, VS Code does not support debugging applications running on the Desktop .NET Framework. The ASP.NET MVC Application (though ASP.NET Core is supported) are not recognized by VS Code. Hence VS Code is lightweight tool to edit a file, they are recommending to use Visual Studio Community.
For Visual Studio Code 1.30.2 I've got it configured to build and run my ASP.NET applications in IISExpress using the following setup.
Terminal -> Configure Tasks
Then select Create tasks.json file from template entry.
Once you do that then select the MSBuild template
This will create the default MS build task template.
You should be able to copy the following to the task.json file:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
//Task for building your ASP.NET Solution
{
"label": "build",
"type": "shell",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/t:build"
],
"windows": {
"command": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\MSBuild\\15.0\\Bin\\msbuild.exe"
},
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "always"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
},
//Task for running App in IIS Express
//You can add additional projects here if you want to run more than one project in IIS Express
//For example this shows how I'm running my WebApp and API locally in IIS Expresse
{
"label": "iisexpress-WebApp",
"type": "shell",
"windows": {
"command": "C:\\Program Files (x86)\\IIS Express\\iisexpress.exe"
},
"args":[
"/path:${workspaceRoot}\\Web",
"/port:52945"
],
"presentation": {
"reveal": "always"
}
},
{
"label": "iisexpress-API",
"type": "shell",
"windows": {
"command": "C:\\Program Files (x86)\\IIS Express\\iisexpress.exe"
},
"args":[
"/path:${workspaceRoot}\\Api",
"/port:49243"
],
"presentation": {
"reveal": "always"
}
}
]
}
Once you save the file just hit Ctrl + Shift + B and select the Build task from the window. If all goes well you should see the output displayed in the terminal below.
Then to spin up your Apps in IIS go to Terminal -> Run Task
That window will then show your IIS Express tasks, select the one you want to spin up and you should see the Output window show IIS starting up. Once that is successful just open your browser and navigate to localhost:{portyouconfigured} and you should see your application running.
I know I'm a little late, but after researching this myself in 2019, I think using VSCode's tasks is a better approach.
Create a tasks.json file inside your project's .vscode folder, this is where the below code will live.
Add the following script to tasks.json, I'm using this to build the project and then run iisexpress.
Once saved, you can run the Build & Run Server task by pressing pressing CTRL+SHIFT+B. You can also just access the available commands with CTRL+SHIFT+P and search for task: run build task.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build & Run Server",
"dependsOrder": "sequence",
"group": "build",
"dependsOn":["Build ASP.NET", "Run IIS EXPRESS"]
},
{
"type": "shell",
"label": "Build ASP.NET",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": true
},
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"windows": {
// change according your msbuild location
"command":"${env:ProgramFiles(x86)}\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\msbuild.exe"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
},
{
"type":"shell",
"label": "Run IIS EXPRESS",
"group": "build",
"windows": {
"command": "C:\\Program Files (x86)\\IIS Express\\iisexpress.exe"
},
"args": [
// change according your project folder and desired port
"/path:${workspaceRoot}\\VSSMVCProj",
"/port:59010"
],
// Show the iisexpress output always.
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
}
],
}
Since Visual Studio Code 1.14
There is a new syntax to create tasks.
In your Menu Click on
Terminal -> Configure Tasks
Create a task in vscode that build your project like so:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"args": [
"${workspaceRoot}\\Some\\Window\\Path\\ToSolution.sln",
"/target:Build"
],
// Path to your msbuild
// The path used corresponds to the path provided by a Visual Studio 2017 installation.
// To find it your msbuild path, go in your file explorer, and search for "msbuild.exe".
"windows": {
"command": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\MSBuild\\15.0\\Bin\\msbuild.exe"
},
"problemMatcher": "$msCompile"
}
]
}
The path used corresponds to the path provided by a Visual Studio 2017 installation.
To find it your msbuild path, go in your file explorer, and search for "msbuild.exe".
I would better recommend you installing dotnet cli to get started on it within 10 minutes as page says. If you're using Linux as I was using CentOS and followed the steps below in terminal:
sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
sudo yum update
sudo yum install dotnet-sdk-2.2
To confirm if dotnet-cli installed successfully:
dotnet
The commmand below sets up a basic asp.net web application in myWebApp folder:
dotnet new webApp -o myWebApp --no-https
cd myWebApp
Simply type dotnet run in terminal to run your first asp.net app This makes your first project run sucessfully. In my opinion, this would work better with Visual studio code than any other method. I use this link source

Clarification on grunt-protractor-coverage syntax for rails app backend?

Background
I'm trying to use the grunt-protractor-coverage in my grunt script to get code coverage for protractor functional e2e tests. To get started, I utilized this tutorial, with some minor modifications and it works perfectly. Using this as a guide, I created a new gruntfile, substituting the "express" app with a rails app backend.
The Problem
When running my gruntfile, I get the following stack trace:
../dummy/node_modules/grunt-protractor-coverage/node_modules/protractor/node_modules/glob/glob.js:130
throw new Error("must provide pattern")
^
Error: must provide pattern
at new Glob (../dummy/node_modules/grunt-protractor-coverage/node_modules/protractor/node_modules/glob/glob.js:130:11)
at glob ../dummy/node_modules/grunt-protractor-coverage/node_modules/protractor/node_modules/glob/glob.js:57:11)
at Function.globSync [as sync] (../dummy/node_modules/grunt-protractor-coverage/node_modules/protractor/node_modules/glob/glob.js:76:10)
at Function.ConfigParser.resolveFilePatterns (../dummy/node_modules/grunt-protractor-coverage/node_modules/protractor/lib/configParser.js:89:26)
at Runner.run (../dummy/node_modules/grunt-protractor-coverage/node_modules/protractor/lib/runner.js:323:24)
at process.<anonymous> (../dummy/node_modules/grunt-protractor-coverage/node_modules/protractor/lib/runFromLauncher.js:32:14)
at process.EventEmitter.emit (events.js:98:17)
at handleMessage (child_process.js:318:10)
at Pipe.channel.onread (child_process.js:345:11)
[launcher] Runner Process Exited With Error Code: 8
Tracing through the code in grunt's task.js file via [node-inspector] (https://github.com/node-inspector/node-inspector), it seems there are two possible issues:
I'm missing some parameter from my config file which would correctly retrieve the files needed
There is a syntax issue
Any idea why it's throwing this error?
My Config File
protractor_coverage: {
options: {
configFile: '/usr/local/lib/node_modules/protractor/referenceConf.js', // Default config file
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
coverageDir: '<%= dirs.instrumentedE2E %>',
args: {}
},
phantom: {
options: {
args: {
baseUrl: 'http://localhost:3000/',
// Arguments passed to the command
'browser': 'phantomjs'
}
}
},
chrome: {
options: {
args: {
baseUrl: 'http://localhost:3000/',
// Arguments passed to the command
'browser': 'chrome'
}
}
}
},
This error means that the plugin was unable to locate your spec files. There were a couple of bugs related to this that have been fixed in recent releases.
You'll generally want your protractorConf.js to be part of your projects. I generally put it in a directory called 'tests'.
So your options would then look like:
options: {
configFile: 'tests/protractorConf.js',
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
coverageDir: '<%= dirs.instrumentedE2E %>',
args: {}
},
You could then put your specs in a 'tests/specs' directory, and in this protractorConf.js, reference them as:
specs: [
'tests/specs/**/*.spec.js',
'!**/exclude.spec.js'
],
This would get any file that ends with .spec.js in /tests/specs and any subdirectories therein, unless the file is named exclude.spec.js.
I had this issue also, for me in my protractorConf file I had to change where my path was.
I originally had
specs: [
'./e2e/**/*.spec.js'
],
which worked fine with protractor, and grunt-protractor-runner
But for some reason, the protractor-coverage, this did not run. I changed it to
specs: [
'test/e2e/**/*.spec.js'
],
and this solved my issue. Basically protractor-coverage looks at the path from the base rather then from the config file.

Resources