Testcafe Initial Set up - testing

I get the error Safari can't open the page "https://localhost:52169/browser/connect/r5cJvcm" because Safari can't establish a secure connection to the server "localhost"
When I try to execute this
testcafe safari TestFile2.js --hostname localhost
The above command does work with chrome however if I try to execute without specifying the --hostname localhost it throws the error ERR_CONNECTION_TIMED_OUT.
How do I get the initial setup properly done to execute testcafe tests
And yes I need to execute the tests while I am connected to VPN
I did try to enable the TestCafe Browser Tools in System Preferences -> Security & Privacy -> Privacy -> Automation and screenrecording. But that did not help.

It is necessary to specify the --hostname option in the case of the VPN connection. It should work in all browsers. For more details please refer to the following thread: https://stackoverflow.com/a/56219385/10448174.

Related

Need to access Firefox browser in remote machine connected using Open Connection in Robot Testcase

Problem statement is:
Execute Robothost Testcase -> used Open Connection keyword to connect to machineX. used Open Browser keyword to open Firefox of machineX.
But instead of opening firefox browser of machineX, browser from Robothost is opening from where testcase is getting executed.
But my testcase execution needs to be done on webpage opened in machineX only.
Since used Open Browser after connecting to remote machine, expecting browser of remote machine to be active. verified that connectivity to remote machine is active.
Below is sample code tried to open browser from machineX
*** Testcases ***
LaunchBrowser
Open Connection ${machineX}
Sleep 5s
Open Browser ${base_url}
Sleep 5s
Input Text //input[#id="normal_login_username"] admin
Input Text //input[#id="normal_login_password"] admin
Click Element //button
Sleep 5s
Capture page screenshot filename=output5g.png
Close Browser
Any suggestions to handle this scenario
This is not how the ssh library works, in order to execute something on the machine x you need to use ssh library keywords. The selenium library will be executed on your machine.
You can install robot framework on machine x and execute the test there. Otherwise you cannot use ssh library. You can trigger the test from your machine if you have to do this remotely.

TestCafe - How to automatically run the generated remote connection URL on a remote browser

I'm new to TestCafe. I have a requirement to execute the TestCafe automated tests on Internet Explorer(IE) browser.
I'm using TestCafe Studio to record the tests and the TestCafe docker container will be used to run the tests within the pipeline. Since the docker container doesn't support test execution with IE browser. I tried out the "remote" option and got a remote connection URL generated.
Which I need to copy and paste in to the remote IE browser where I want to execute the tests. Is there any way that I can automatically triggers test execution with the generated remote connection URL without manually copy and paste the URL?
docker run --add-host=my.host:127.0.0.1 -p 1337:1337 -p 1338:1338 -v /Users/Documents/GIT/Projects/e2e_tests:/tests -it testcafe/testcafe --hostname my.host remote -q --skip-js-errors --assertion-timeout 20000 --selector-timeout 20000 '/tests/Tests/**/*.testcafe'
You can write a script (using Batch/PowerShell, etc.) that starts the TestCafe container with a remote mode enabled and then navigates Internet Explorer to the connection URL, which is http://${HOSTNAME}:${PORT1}/browser/connect (where HOSTNAME and PORT1 are variables that were used to launch TestCafe). Check out this answer. It contains a bash script that implements this approach for the automation of test launch in the Safari browser using the remote mode.
Also note that TestCafe allows you to use browsers from cloud testing services. BrowserStack and Sauce Labs services provide Internet Explorer among many other browsers, so I assume it would be simpler to make your tests run in IE.

debugging chrome remotely - doesn't open websocket

Im running chrome headless through chromedriver and selenium via python.
I've run into the following issue both on Mac and Linux.
Im starting chrome as follows:
if self.headless:
options.headless = True
options.add_argument("--headless")
if self.debug_port:
logging.info(f"Setting up remote debugging on port {self.debug_port}")
options.add_argument(f"--remote-debugging-port={self.debug_port}")
options.add_argument(f"--remote-debugging-address=0.0.0.0")
If I connect to http://localhost:9222 from another headed instance of chrome I can see the list of sessions and connect to it seamlessly. At which point i have a window opened up with a screencast of the remote session and the dev console.
Here's that successful example:
When I connect to http://192.168.1.194:9222 I get the list of sessions just fine and upon selecting one the dev console opens but it doesn't start the websocket connection to ws://192.168.1.194 so the screencast and remote debugging capabilities are not available.
Here's that failed example:
I've captured har files and uploaded them here if you want to take a look
Using the following steps I was able to debug remotely. However the screencast functionality did not work. Ultimately that's what I needed so this is only a 50% solution in my case.
So, as noted above in the comments, what's blocking remote debugging from working is that the chrome debugger links out to https://chrome-devtools-frontend.appspot.com/..... and passes a value of ws://192.168.1.194 for the websocket parameter. Any browser will inherently block this, based on it being mixed content - i.e: https + ws
What's needed here is to run the chrome dev tools frontend on a http server
and direct your chrome instance to that server instead of the appspot instance.
Solution Steps
1 Install depot_tools (pre-requisite for building)
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
2 Checkout the devtools-frontend repo
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#checking-out-source
3 Build chrome devtools frontend
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#build
4 Start the devtools-frontend http server
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#running-in-hosted-mode
5 Run 2 instances of chrome and use one to debug the other
5.1 Start first instance of chrome headless
...with remote debugging enabled. See the python way in the question above or do it from the command line with the same arguments
5.2 Start a second instance of chrome
...using a different user data dir --user-data-dir=<some-path>
5.3 Navigate to http://192.168.1.194:9222
Use whatever the IP address of the first chrome instance is and the port that you chose.
5.4 Create a link to the local dev server
The 2nd instance of chrome will now be showing you links to debug each of the open tabs of the 1st instance. However the links will still to go https://chrome-devtools-frontend.appspot.com/..... You'll need to copy n paste the link you want and replace the hostname with the hostname of the devtools frontend that you started in step 4
Walla!!
If you figure out how to get the screencast working please comment below! 🙏
N.B:
I also tried using the npm run server command in the devtools frontend but for some reason that server didn't work at all ¯\_(ツ)_/¯

Testcafe: How to wait for the remote runner to be waiting/accepting connections before launching my browser?

First and foremost, the "remote" function of Testcafe is easily one of the best and most portable browser testing implementations I have ever come across; excellent work to the team developing it.
When I run npx testcafe remote ./tests --ports 5567,5568
The runner will notify me that it's listening on http://localhost:5567/browser/connect. Fantastic, now I want to launch my browser and navigate to this URL.
My browser might be a headless browser inside a docker container, or it could be a remote server running MacOS - regardless of its location, the remote needs to be issued commands after the test runner is ready and accepting connections.
Is there an endpoint like /ping or something that I can send a request to that will notify me of the test runner's active status?
npx concurrently \
"npx wait-on http://localhost:5567/ping && remote-browser-util IOS_SAFARI http://localhost:5567/browser/connect" \
"npx testcafe remote ./tests --ports 5567,5568"
TestCafe is ready to accept browser connections as soon as specified ports are occupied. So you can use wait-on tcp:5567 to delay the start of your browser.

Selenium RC and Internet Explorer 7 with rspec for HTTPS and HTTP connections

We test our rails web application with rspec and use the selenium-client (gem version 1.2.18) API in our rspec tests to let selenium RC server (version 2.21.0) steer internet explorer 7 under AP to test our application.
This worked very well until we introduced HTTPS for our login and registration process. Now the user is redirected to the secure version of the login and registration form and afterwards redirected back to the unsecure HTTP site.
For our selenium tests to work with HTTPS and internet explorer 7 we are setting up the selenium driver with "*iexploreproxy" instead of "*iexplore" and use port 4444. We also installed the CyberVillans SSL Certificate as describe here http://blog.mogotest.com/2010/04/13/how-to-accept-self-signed-ssl-certificates-in-selenium/. We run selenium rc server with -trustALLSSLCertificates. This solved the self signed SSL Certificate issues (be aware that selenium RC > 2.21 does not work because of a bug which sets a wrong valid from date).
After that we received "Permission Denied" errors, when running our tests. We found out that this is because of the same origin problem described at http://wiki.openqa.org/display/SEL/Selenium+Core+FAQ under "Why do I get a Permission Denied error when accessing my website via HTTPS?". This problem can be solved by adjusting internet explorers 7 proxy settings and using localhost:4444 to route everything through the selenium RC server. It works, but the problem is that after every test run the proxy settings are reset.
My first question is: How is it possible to make those settings persistent in the internet explorer 7? I read about custom profiles for IE but I haven't found out how to set this up for rspec tests. I also read about a proxy.pac file, but googling for solution without success.
The next problem is that when running our tests we also run into "Access denied" errors by selenium. I have no idea how to solve these and why they occur. So my second question is: How do I get rid of those under the setup described.