How can I debug a websocket connection? - testing

When running within a testcafe test, upon loading an app that tries to connect to a websocket, I receive an error in the console of "Connection closed before receiving a handshake response"
This prevents most of the app from working.
How can I get additional information about what the final request that testcafe is making after url-rewriting? I'd like to see exactly what url & headers it's sending to try to connect.
Simple example:
import { ClientFunction, Selector } from "testcafe";
fixture`Getting Started`.page("https://torus.qa.argos.education/session/new");
test("Example error", async (t) => {
await t.debug();
});
I've tried chrome with both non ssl and self signed certificate mode, and also tried disabling web security. Firefox gives the same error.

We released a new TestCafe version (v2.3.0), which includes experimental proxyless mode. This mode uses native browser automation. In Proxyless mode, a few issues are already fixed. This issue should also be fixed in Proxyless mode.
Unfortunately, I was not able to test your web site since the URL you shared is no longer available. Would you please check if your sample is working correctly in v2.3.0 with experimental proxyless mode enabled?
This option is available in all interfaces:
// Command-line
testcafe chrome tests --experimental-proxyless
// Programmatic
const testcafe = await createTestCafe({ experimentalProxyless: true });
// Configuration file
{
"experimentalProxyless": "true"
}
Please keep in mind that this mode is still experimental and is implemented only in Google Chrome. It will not work correctly if you run tests in a non-Chrome browser or in a combination of other browsers.

Related

How can I browse the web randomly in a Chrome instance with a logged in Chrome extension?

I want to test a Chrome extension and to test it I need to have it browse the web randomly and visit random pages for a long period to see if it generates any errors. You need to be logged into the extension, which is why I am not using Selenium for this as I cannot find a way to log into the extension using Selenium.
Is there a way to make Selenium act on an existing or pre-set Chrome existence? Any other options?
You can use web-ext. You can use Firefox, google Chrome, Chromium.
You can script your browser like this.
import webExt from 'web-ext';
webExt.cmd.run({
// These are command options derived from their CLI conterpart.
// In this example, --source-dir is specified as sourceDir.
firefox: '/path/to/Firefox-executable',
sourceDir: '/path/to/your/extension/source/',
}, {
// These are non CLI related options for each function.
// You need to specify this one so that your NodeJS application
// can continue running after web-ext is finished.
shouldExitProgram: false,
})
.then((extensionRunner) => {
// The command has finished. Each command resolves its
// promise with a different value.
console.log(extensionRunner);
// You can do a few things like:
// extensionRunner.reloadAllExtensions();
// extensionRunner.exit();
});
There should be an option to define --start-url. You can make this a random url with some programming... Not able to test it now, but you should be able to make it work
Or you just run from the commandline
web-ext run --start-url www.mozilla.com

ERROR: Component interaction/ListenChange not available with base

I wanted to run a NoFlo application. I created a noflo component in json fomat and then I tried to run it with the following command:
./node_modules/.bin/noflo-nodejs --graph graphs/Number_game.json.
I got the following error:
NoFlo runtime is now listening at ws://192.168.43.64:3569 Browsers
will reject connections from HTTPS pages to unsecured WebSockets You
can use insecure version of the IDE, or enable secure WebSockets with
--tls-key and --tls-cert options Live IDE URL: http://app.flowhub.io/#runtime/endpoint?protocol%3Dwebsocket%26address%3Dws%3A%2F%2F192.168.43.64%3A3569%26id%3D173bb627-f1df-48cf-80da-d2b72546c08c%26secret%3Dtupiqiyoma
Component interaction/ListenChange not available with base C:\Users\DELL\Desktop\my-app
Can someone please help me with this issue?
(Sorry I can post images related to it because I am a new user)
noflo-interaction components are only available for browser environment. So they're not visible to noflo-nodejs.

Strange getUserMedia issue?

I'm working on an html application that uses getUserMedia. It works great so far but there is one little problem:
The web application is also being called from local file system. That means file://.
Ok, WebRTC is unavailable in this case. When the Browser tries to call
navigator.getUserMedia({video: true, audio: false}, function(localMediaStream) {...}, function(error) {alert("blabla webrtc unavailable";)});
it should run into an error and call the error callback.
In case of file://, none of these two callbacks will be ever called.
In another case, the web application is running over regular http://, a warning is given, that the WebRTC feature is unavailable in insecure environments, but here the error callback is working as expected.
I need the error callback to tell the user, that WebRTC is unavailable.
What is wrong here?
(It is used for an unimportant feature. And only getUserMedia() is used, not the entire WebRTC-Workflow. But it is ugly, if it run into a blank screen)
And no, there is no waiting popup which ask the user for permission :-)
The problem is Chrome only. Probably a Browser bug?
Thanks.
Silently failing for file:// is documented Chrome behaviour, see here. If you can control Chrome, the allow-file-access-from-files flag enables getUserMedia from file urls.

No Alert Found using Chrome Driver

Using ChromeDriver 2.14, selenium server 2.47.1 and Chrome 45. I am attempting to handle a basic authentication prompt. I have tried the following code to try and resolve this.
var wait = new OpenQA.Selenium.Support.UI.WebDriverWait(Driver.Value, new TimeSpan(0,0,60)).Until(OpenQA.Selenium.Support.UI.ExpectedConditions.AlertIsPresent());
Driver.Value.SwitchTo().Alert().Dismiss();
And this
Driver.Value.SwitchTo().Alert().SetAuthenticationCredentials("test", "test");
and this
while (true)
{
try
{
Driver.Value.SwitchTo().Alert().SetAuthenticationCredentials("test", "test");
break; //this is brute force I know
}
catch
{
Thread.Sleep(100);
}
}
No luck, they all throw a "no alert found" exception. We would switch to firefox, but it is an internal application and we only support IE or Chrome.
I didn't find a way to use the authentication options inside Selenium with the basic authtication prompt. Instead I found that if you run fiddler in the background, you can have it auto-authenticate for you when prompted based on a specific site. Then the popup never shows up and your Selenium scripts run just fine.
Auto http authenticate traffic for a specific site with fiddler

Is there a bug with Worklight on IE 10?

I've been working with a business partner to get an insurance app working on a Windows 8 tablet and have come across some interesting behavior that I can't explain.
I have managed to recreate the problem using a very simple use case and it appears to fail in the browser as well as when deployed as an app.
To re-create
Create a simple WL Hello World app with no JavaScript libraries
Deploy it to the development server
Open up an IE 10 browser and launch the WL Console.
Run this app using "Preview as Common Resources" and it should work fine (showing the default Hello Worklight)
click F12 to launch the IE debugger and then refresh the browser, click on the show console button to verify there were no errors
Add a WL.Client.connect(...) call into the wlCommonInit method
...
WL.Client.connect({
onSuccess: function(data) {
console.log("connection Successful");
},
onFailure: function(err) {
console.log("Connection FAILED: " + JSON.stringify(err) );
}
});
Save and re-run the app and it fails with an InvalidStateError (verify with F12 debugger)
Open up either a Chrome or Firefox browser to the WL Console page and click the "Preview as Common Resources" and open the developer tools for either and the console shows the connect call succeeding.
Is this a known problem or is there something that I've missed?
The ultimate goal is to deliver a Windows 8.1 tablet app however every time we tried to run the app it failed with this error. After some debugging I thought maybe it has something to do with the OS and tried to replicate it in just the browser with minimum code.
Through testing I've found that the basic Hello Worklight app with a WL.Client.connect() fails on IE but works on other browsers.
So I'm thinking if I get it working in IE browser, then that fix will be good for the tablet app as well.
Any pointers or guidance would be appreciated.
Note I am using WL v6.2 (6.2.0.00-20140915-1601)
Tested on Windows 7 - IE 10.0.9200.17089
Tested on Windows 8.1 - IE 11.0.9600.16663
The error I get is
HTML1300: Navigation occurred.
File: index.html
wlclient init started
before: initOptions.onSuccess
Request [/Connect/apps/services/api/Connect/common/init]
console.trace()
at __log (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:4882:31)
at Anonymous function (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:5240:7)
at createRequestHeaders (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:3200:17)
at sendRequest (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:3266:18)
at initialize (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:3172:17)
at klass (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:524:4)
at sendInitRequest (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:7870:5)
at connect (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:7879:3)
SCRIPT5022: InvalidStateError
File: worklight.js, Line: 1055, Column: 3
Uncaught Exception: InvalidStateError at (compiled_code):1055
For future readers, this problem was resolved by moving to a newer fixpack release v6.2.0.00-20141002