Cypress extension load into test runner iFrame - iframe

I am trying to test a chrome extension with cypress and can successfully load the extension into cypress using the before:browser:launch event.
This will successfully install the extension to the browser, but the extension does not run in the same context as the test runner iFrame and therefore cannot get information from the page within the test runner.
I have also tried to install an older plugin called cypress-browser-extension-plugin to load the extension into cypress which does not seem to be working. Has anyone been successful loading an extension into the actual test runner of cypress without having to heavily modify the extension to be injected into the test runner?
I'm not sure how loading the extension into cypress the default way where it's installed on the browser but not running in the test runner iFrame is helpful for writing tests against the extension, ideally the extension would be running inside the test runner and able to interact with the page that cypress is currently testing right?

While running in to the same problem I found this answer in another thread: https://stackoverflow.com/a/72876307
Just add "all_frames": true to your extensions manifest.json under the "content_scripts" section.
Link to the docs: https://developer.chrome.com/docs/extensions/mv3/content_scripts/#frames
I created a minimal reproduction repo for the solution as well: https://github.com/leonbubova/cypress-chrome-extension-minimal-reproduction

Related

How can you make a client-side javascript pages with scala.js and sbt's ScalaJSBundler?

I'm using scala.js to create javascript code to be run in a browser, served up by an akka-http server. I had it mostly working using mill as my build tool, but then wanted to switch to sbt so I could use the ScalaJSBundler plugin for npm dependencies and packaging. Using sbt, when I do a fastOpt to compile my scala.js code, javascript code is created slightly different than what mill created and it now includes require statements (which the mill build didn't) such as
var $i_react = require("react");
When this code is run in my browser require comes up as undefined. Also variables I have exported in scala.js come up as undefined. I thought this was because the code being created was for ModuleKind.CommonJSModule (set via the sbt setting scalaJSModuleKind), but when I try to change that to ModuleKind.ESModule the build fails with:
scalaJSModuleKind must be set to ModuleKind.CommonJSModule in projects where ScalaJSBundler plugin is enabled
I'm new to javascript (and scala.js). What am I doing wrong? How should this be done?
Thank you!
As described in the Getting Started of scalajs-bundler, you should serve the result of webpack/fastOptJS to the browser, instead of fastOptJS. This is necessary because the latter is emitted as a CommonJS module, unsuitable for the browser, but then processed by Webpack to produce the former, a bundle suited for the browser, also containing the npm dependencies.

Ionic push: web client incorrectly installs

Following the guidelines here: http://docs.ionic.io/docs/push-from-scratch I am having trouble with step 2 - installing ionic add ionic-platform-web-client.
My index file within my app adds <script src="lib/ionic-platform-web-client/dist/ionic.io.bundle.min.js"></script> as it should, however the file doesn't exist at this location, even after running 'ionic lib update'.
(For ease of explanation in this section I am using the non minified version of the bundle: ionic.io.bundle.js (the results are the same with both full and minified versions of the files)).
Manually adding ionic.io.bundle.js from https://github.com/driftyco/ionic-platform-web-client/tree/master/dist will give me this error:
"Uncaught TypeError: Cannot call method 'get' of undefined
ionic.io.bundle.js (3429,0)"
from this code:
key: "get",
value: function get(name) {
return this._settings.get(name);
}
I found a 'hacky' way to get the dev pushes working by simply returning this instead of the full return this._settings.get(name) statement, although this only really suits the purpose of debugging and additionally does not allow removal of developer mode by settings 'ionic config set dev_push false' or manually setting "dev_push":false in .io-config.json.
I am unsure as to whether manually adding ionic.io.bundle.js is simply adding to my problems or whether this is the right approach to take and that the errors produced are the real problem?
I am running:
ionic 1.1.0
ionic CLI 1.7.7,
cordova 5.3.3,
bower 1.6.2,
npm 2.11.3,
visual studio 2015 community with cordova/ionic setup,
I've also updated my android platform - for which I am currently building to (deploying to nexus 7).
TheCannot call method 'get' of undefined in ionic.io.bundle.js happens because of missing settings in the bundle.
This could be fixed by running:
ionic config build
Although I still haven't been able to install the ionic web platform via 'ionic add ionic-platform-web-client' in the cli I have managed to get the ionic push notifications working.
Firstly I made sure in my app directory within the cli to use 'ionic lib update'. As the setup of my project was different (thanks to visual studio). You will likely already have these files using a custom setup, but I found it's good to have the directories in place.
Secondly I manually downloaded the web client https://github.com/driftyco/ionic-platform-web-client4 not just the ionic.io.bundle.min.js which seemed to fix my "Uncaught TypeError: Cannot call method 'get' of undefined" problem mentioned previously, after I moved the entirety of this in my lib directory. (Make sure the name of the downloaded folder matches: "ionic-platform-web-client" exactly, and doesn't contain any words like master).
Thirdly, as I couldn't add version 1.3.0 of the push plugin (which continually gave me the beloved 'uh oh' error) I used 1.2.3 instead. I installed this via: 'cordova plugin add https://github.com/phonegap/phonegap-plugin-push.git#1.2.31'. Although I have just noticed 1.4.0 is available which may also work?
This should hopefully fix any issues you have, even if it's not a perfect solution. As a side note: I know it is mentioned somewhere on one of the ionic pages that you need to have a traditional project setup and then move the relevant files but it would be nice to have some description of how to go about this - as you may not know what the relevant files are. For anyone who comes here scratching their heads, If you're using visual studio to create your ionic projects from scratch or any other custom setup, you will likely run into the same issues, as the relevant directories created using 'ionic start myApp' will likely have been omitted.

Using Selenium WebDriver, Protractor with Scalatest in an SBT project

Our project setup is as following:
We are using 'Play framework' and SBT as a build tool.
We have Jenkins for continuous delivery
We are using Scalatest for writing Selenium tests
Additionally we have Sonarqube for consolidating test results.
For Frontend we are using AngularJS for dynamic content.
We wanted to use Protractor as it can access AngularJS specific elements, but installing it locally is not what we want. Instead we want to have a dependency listed in Build.scala file and somehow we should be able to write Protractor code in Scalatest. How to go about it?

postMessage not declared in this scope error when building nativeClient plugin

When I am trying to build the plugin module using .\scons it is raising me errors. What might cause these types of errors...? Error is
postMessage() was not declared in this scope.
I am using pepper_16 version. Here is the procee I did
Installed Python and gave the path required(Installed in D drive as I do not have privileges).
Downloaded nacl_sdk.zip extracted in the same folder where I have installed python and updated the tools with nacl_sdk.bat update
Enabled NativeClient form about:flags window and executed the server using httpd.py file.
And created project in Pepper_16/examples/TestApp using init_project.
Written the code as it is in the Getting started tutorial to test.
Then using ./scons in the same project folder in cmd mode I have tried to build
The above process worked fine for me where I have admin privileges. But the same procedure and same code not working where I do not have admin privileges.
Please let me know if any further details are required.
which source file was being compiled? a lengthier cut-n-paste of the output around the error message would help to give context.
also, when you say the plugin module, are you referring to NaCl itself or your own PPAPI plugin? normally NaCl's plugin is built into Chromium using gyp, and while scons can be used to build the NaCl plugin it is typically only used for testing, via the --register-pepper-plugin command line argument to chrome.

running html version of playn

I have playn installed on eclipse (http://code.google.com/p/playn/wiki/GettingStarted#Running_via_Eclipse), i loaded the sample programs and they load file, the java one runs fine. But for html
I right click the showcase-html > google > compile
I don't get any errors:
Compiling module playn.showcase.Showcase
Compiling 1 permutation
Compiling permutation 0...
Compile of permutations succeeded
Linking into C:\Users\(my path)\playn-samples\showcase\html\target\playn-showcase-html-1.0-SNAPSHOT\showcase
Link succeeded
Compilation succeeded -- 12.208s
then
run as > web application
I get a url in the development tab:
http://127.0.0.1:8888/Showcase.html?gwt.codesvr=127.0.0.1:9997
when I run this it hangs my browser
when I run this:
http://127.0.0.1:8888/Showcase.html
it says "GWT MODULE MAY NEED TO BE (RECOMPILED)" on a popup and loads nothing.
Any idea what might be wrong?
I don't recommend using Eclipse to compile and test the HTML5 backend of a PlayN game.
Develop and test using the Java backend, and when the time comes to build the HTML5 version, use the Maven command line to build and test it. It is far more reliable.
However, if you insist on testing the HTML5 backend in Eclipse, you have to be careful. What you've done above is to first compile the Java code to JavaScript (by using Google -> Compile) and then overwritten the compiled JavaScript with GWT devmode stubs (when you used Run as -> Web application).
Instead, you should use Google -> Compile, and then expand playn-showcase-html -> target -> playn-showcase-html-1.0-SNAPSHOT and right click on Showcase.html and select Open With -> Web Browser. EDIT: You'll need to run the generated code in a webserver to avoid crosssite scripting issues.
You never want to use GWT devmode (Run as -> Web application) to test the HTML5 backend of your game, because GWT devmode is pathologically slow for running high-performance code like an HTML5 game.

Resources