UI selenium Test in Azure devops Release - selenium-webdriver

I am trying to create a release pipeline with IIS deployment and after that, there is UI Selenium test project.
Everything is working fine except the file uploader. How to handle file uploader?
VSTS Agent is not allowing to get the file from the project folder.
I tried to put the file in Sharepoint and get the stream from there and try to save in the project directory but still, it is not allowing to save file.
var directory = Assembly.GetAssembly(typeof(HelperClass)).Location;
Console.WriteLine(directory); var newDir =
directory.Replace("\\bin\\Release\\MarloTest.dll", "\\bin\\Release");
Console.WriteLine(newDir);
if (Directory.Exists(newDir)) return newDir;
(var file= new FileStream(newPath, FileMode.Create))
{
var streamFile = stream; streamFile.CopyTo(file);
}
Thanks in Advance

What agents are you using to fire your UI tests from your release pipeline? If its Hosted agent, I doubt it works. Try installing the agent of your own and trigger a release. For running Selenium UI tests, you can refer here.

Related

.NET / React App not serving /.well-known/filename

I'm trying to setup Apple Pay via Stripe, which requests access to a file to verify domain ownership. The problem I'm having is that this file has no extension, so either React, Azure or my .NET application does not like it!
I've tried various solutions to date within the web.config but to no avail.
The file in question is: /.well-known/apple-developer-merchantid-domain-association
My project is a .NET project running a React SPA. I've added the file mentioned above to the /public folder, too.
I can access .txt files in the same folder, so the path/folder is accessible - It seems to be a problem with the lack of extension.
I've managed to resolve this with the following, and ensuring the ./well-known and subfiles are in my project root.
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, #".well-known")),
RequestPath = new PathString("/.well-known"),
DefaultContentType = "application/json",
ServeUnknownFileTypes = true
});

Websocket connection to 'wss:localhost:60001/w' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

I just started learning about React.js and I have been noticing in my developer window (F12) some spamming errors.
These were all the steps I did:
Open Visual Studio 2019
Create a project ASP.NET Core with React.js
Choose .Net Core 5.0
Left the option "Configure for HTTPS"
I pressed Play after the project finished loading
Clicked the F12 key and I noticed the errors popping up in the Console
I have gone through a lot of forums where people have posted about this issue but all of them have to do with people setting up their own "WebSocket Handlers". These people are actively working with web socket code. I haven't even learned web sockets yet. I found one website that remarked that I didn't have my script debugging enabled. So I did that but I still see the same error.
I notice in the error log that it points to WebSocketClient.js, line 16. But all that is located in ClientApp->node_modules and I have nothing to do with that directory or anything to do with those files.
My question is this: is the error happening because my visual studio project is not configured properly? If so, how do I fix my project in order to correct this issue? Many thanks in advance.
It's an issue with cra5 aka react-scripts v5:
To solve you need to add a .env file in the same folder where package.json is present.
In .env file put WDS_SOCKET_PORT=0, '0' means that it will dynamically pick whatever port on which local server is running.
Also need to add/uncomment the middleware UseReactDevelopmentServer in Startup.cs file. So it can be used as proxy to node dev server as v5 not using react-web-utils directly.
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});

CefBrowser not loading after deployment using wix

Hi I am new to CefBrowser .
When executing the solution from visual studio then the browser is working fine.
But after the development phase when i tried to load the Cef browser directly after deployment the browser is not loading .
The difference i found in the development and deployment stage is When running from VS CefSharp.BrowserSubprocess.exe is running in the task manager but its not running after the deployment .
Am i missing anything ? I have copied all the files from the debug folder too .
Arshad
Thanks #amaitland for the help and suggestions.
Issue got solved after Initializing the CEF browser and setting the absolute path for CefSharp.BrowserSubprocess.exe
if (!Cef.IsInitialized)
{
CefSettings cefSettings = new CefSettings();
cefSettings.BrowserSubprocessPath = path; // **Path where the CefSharp.BrowserSubprocess.exe exists**
cefSettings.CachePath = "ChromiumBrowserControlCache";
cefSettings.IgnoreCertificateErrors = true;
Cef.Initialize(cefSettings);
}
Arshad

How can I import data from a REST call, json feed into a SQLite database on a MAC?

I have data that's on my server in a SQL Server database. I can access that with a REST call into a C# ASP.Net Web.API that I have control over and it will return json data. Possibly I can get that to return other formats of data but I am not sure about that. I have full access to the server application and the json it creates.
On my development Mac I am using DB Browser for SQLite and Xamarin to develop a multi-platform app. I have a small SQLite database created.
How can I import/insert the JSON data from some of my tables on the server to tables in the SQLite database that I create on my MAC? I need to do this manually but I would like to automate the process of doing the import into a bash script or something similar that I can run with a command.
I have researched this but don't seem to be able to find any examples of how to do it so I opened up a bounty in the hope that someone could give an answer that would be a big help to me and to others.
Off the top of my head, you have two options that you can do:
Make a simple Xamarin.Mac app that does this. Similar to how windows folks might make a console app. Just have it have one button and call pretty much the same code in your xamarin app to download the data and dump it into a sqlite db.
A better option, would be to write a "unit test" (or integration test for those hardcore peeps) that calls the existing code in your xamarin app and writes it to a sqlite db on the file share. Then you can do this as often as you want with a run of a unit test. This could be done in your test runner in Xamarin Studio (Visual Studio or anything that has a test runner). I would use either nUnit or xUnit since they great cross-platform support.
In my previous app, I had XUnit tests that checked to make sure the API calls were working and other tests to ensure that my SQLite.Net-PCL code was working. You could combine that into a single "test" to download the data into a db3.
This assumes you abstracted your code out. If not, you could just copy and paste it. Either way, if you are using x-plat nuget packages the code will work on desktop or mobile app.
i would use node js to write a script using javascript.
install nodejs. https://nodejs.org/en/download/ or
brew install node
create a directory to work on your project
mkdir myimporter
cd myimporter
install the required libraries in the folder
npm install --save request sqlite3 moment
npm install -g nodemon
open the folder or app.js with your favorite text editor
save the following code as app.js
var request = require('request');
var sqlite3 = require("sqlite3").verbose();
var moment = require("moment");
var url = 'http://www.google.com';
var s, e;
var fs = require("fs");
var file = "test.db";
//var file = process.env.CLOUD_DIR + "/" + "test.db";
var exists = fs.existsSync(file);
var sqlite3 = require("sqlite3").verbose();
var db = new sqlite3.Database(file);
// use same exists from checking if db exists, with assumption that table would exists in a new db.
if(!exists){
db.run("CREATE TABLE Stuff (thing TEXT)");
}
function saveResultTosqlite3(message){
var stmt = db.prepare("INSERT INTO Stuff VALUES (?)");
stmt.run(message);
stmt.finalize();
}
s = moment();
request(url, function (error, response, body) {
e = moment();
var elapsed =e.diff(s,'milliseconds');
var responseCode = response.statusCode;
if (!error && response.statusCode == 200) {
console.log("successful request");
}
var message = 'request to ' + url + ' returned status code of ' + responseCode.toString() + ' in ' +elapsed.toString() + ' milliseconds' ;
console.log(message);
saveResultTosqlite3(message);
});
run the follwing terminal to run the script each time it changes, for development / testing
nodemon app.js

IntelliJ: Automatically update resources

I am using IntelliJ IDEA to develop AngularJS app with Java back-end. HTML/JS is server from Tomcat.
Whenever I changed HTML/JS file, I hit CMD+F10 and select Update resources, then refresh my browser and everything is OK.
I'd like to ask if there is a way that IntelliJ would do this automatically for me. I know that I can check 'Don't ask again', but sometimes I really want to Redeploy or Restart server as well ...
If you go into your Server Run Configuration, on the Server tab there is an option named "On frame deactivation". Set that to "Update resources" and then whenever IDEA loses focus, it will update the resources of the server.
Relevant docs from Intellij http://www.jetbrains.com/idea/webhelp10.5/updating-a-running-java-ee-application.html#update_on_frame_deactivation
Edit 8/19/2020
Thanks to Adi Gerber for providing an updated link, which is https://www.jetbrains.com/help/idea/2016.2/updating-applications-on-application-servers.html#update (the previous one doesn't work anymore)
And here is a link to the current docs as of 8/19/2020: https://www.jetbrains.com/help/idea/updating-applications-on-application-servers.html#update
Another TRUE AUTOMATED APPROACH that works very well is :
Having an imported Maven project
Option: Build Tools > Maven > Importing > Import Maven Project Automatically to keep in sync IDE compiler options specified in POM ( for example maven-compiler-plugin options)
Plugin: File Watcher to watch for resources' updates
Option: Tools > File Watcher > Custom watches to copy updated files via mvn war:exploded ( in our case Javascript and HTML )
Option: Build > Compiler Build Project Automatically to update .class
In our case we deploy on Google Cloud App Engine Devserver which reloads files everytime they are updated

Resources