how to create self hosted playwright trace viewer - playwright

how do I create https://trace.playwright.my.local ?
as of now trace itself is not static website itself and requires some pre-processing
https://github.com/microsoft/playwright/issues/9026

You can try opening the saved trace using the Playwright CLI. For example, here is a tutorial on how to use the trace viewer locally.
Essentially:
npx playwright show-trace trace.zip # with a zip
npx playwright show-report # show report after running `npx playwright test --trace on`
will end up displaying this:

Related

How to change directory for launching `npx folio`

I want to start using Microsoft Playwright for my web application. When running npx folio to start my tests its targeting this folder by default C:\Users\john\AppData\Local\ms-playwright\firefox-1225\firefox\firefox.exe but that is not where I want it to target.
It results in an error when running npx folio because firefox.exe does not exist in that directory
C:\Users\john\AppData\Local\ms-playwright\firefox-1225\firefox\firefox.exe does not exist...
How do I get pass this?

How to run cypress open with electron

I am having issues with cy.visit hanging in electron only, but chrome is fine. There are no errors in the console with cypress run, so would like to run cypress open with electron, but not sure how. cypress open --browser electron or node_modules/cypress/bin/cypress open --browser node_modules/electron/dist/Electron.app/Contents/MacOS/Electron doesn't work.
I have tried cypress run --headed but cypress run doesn't allow you to stop the test mid way through and investigate what is wrong. Pausing the test closes the window.
As stated in the docs about the open command, the browser flag is used only to specify a path to a custom browser to be added to the list of available browsers in Cypress. Electron being the default browser bundled with Cypress, you don't have to specify it when launching the UI. You can choose any browser you need on the UI before launching a test suite (see screenshoot).

Appium - AWS device farm

I get an error as below when I try to run my tests on device farm.
testAppiumMethod failed: Invalid server instance exception has occured:
There is no installed nodes! Please install node via NPM
(https://www.npmjs.com/package/appium#using-node-js) or download and
install Appium app (http://appium.io/downloads.html)
I have installed Appium globally on local machine and the tests run fine. But they fail on device farm(have included all the dependencies). Can somebody help me out?
I believe you are trying to invoke the Appium server through your code, which is not required in Device Farm. Device farm has a Test Spec file (which is a yaml file) which does it for you, so all yo need to do is connect your driver to the invoked Appium server.
When you get the chance would you be able to provide this info:
appium verion being used
Specific method that the this failed on/code
snippet
Programming language Java/python
How exactly are the test being packaged and uploaded? Are we using the web console or the SDK/CLI?
Is this a web app tests or native app tests?
Also, to rule out an issue with a specific device would we be able to run the AWS Sample app/test on the same device?
Assuming this is an android test execute these commands to build the sample app:
git clone https://github.com/awslabs/aws-device-farm-sample-app-for-android.git
cd aws-device-farm-sample-app-for-android/
./gradlew cC
The app-debug.apk should be located in ./app/build/outputs/apk/
Then clone the sample appium testng tests:
git clone https://github.com/awslabs/aws-device-farm-appium-tests-for-sample-app.git
cd aws-device-farm-appium-tests-for-sample-app/
mvn clean package -DskipTests=true
The test pacakge "zip-with-dependencies.zip" should be located in the ./target directory
My apologies for adding all these questions as an answer. I look forward to your response.
HTH James
Seems to me that you need to install node on your AWS instance.
See below:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

How to debug browser tests with the new test package

browser tests need to be run from command line like pub run test -pdartium. Is there a way to debug such tests.
The Dart team is working hard to make tests with the new test package debuggable. Until the related issues are fixed you can use this workaround:
To run browser tests with the new test package, for example from WebStrom, including debugging, just replace the <x-test-dart ...> tag with a normal Dart script tag pointing to your test file and run it like any Dart browser application from WebStorm.
This also works for Polymer tests. Ensure you run await initPolymer(); or the appropriate initialization necessary for the used Polymer version.
I usually create a copy of the test entry page file where I can keep the replaced script tag.
pub run test -pdartium --pause-after-load
starts the test only after I click a "play" button on the test page. This gives me time to open up Dev Tools in Dartium and set breakpoints. I can also open up the Observatory and do stuff there.

Is there a way to get JUnit code coverage when running in the browser?

We are currently working on getting better code coverage for one of our JS libraries. I have the The Intern up and running, and can run tests in the browser. However, our libraries create DOM elements in some of their functions, making it so we can't run JUnit from the terminal because Node.js doesn't allow for DOM construction in tests. Is there a way we can get JUnit code coverage on the html and console output we get when we run The Intern in the browser?
I found the answer. From this link: https://theintern.github.io/intern/#local-selenium
Using ChromeDriver (Chrome-only)
If you’re just looking to have a local environment for developing functional tests, a stand-alone ChromeDriver installation works great.
1. Download the latest version of ChromeDriver
2. Set tunnel to 'NullTunnel'
3. Run chromedriver --port=4444 --url-base=wd/hub
4. Set your environments capabilities to [ { browserName: 'chrome' } ]
5. Run the test runner
Once you have that setup and running, you can run
node_modules/intern/bin/intern-runner.js config=tests/intern reporters=JUnit filename=junit.xml
This will allow the tests to run in a chrome instance, and then output the results to a report that can then be upload somewhere.

Resources