I have a karma.config.js file in a repo that lists different browsers that karma needs to run test on. If I run the test on ubuntu which doesn't have safari install and karma will complain
No binary for Safari browser on your platform. Please set "SAFARI_BIN" env variable.
How do I configure Karma to automatically skip the browser without giving error if a browser is not installed. I don't want everyone who download the repo to edit the config file.
Let me answer my own question. After some searching and experimenting. I found a karma plugin that Karma detect browsers. In the karma config, I added
detectBrowsers: {
enable: true,
},
and removed the browsers array.
You still have to install the runners for each of the potential browser that you want to test on.
When I run karma now, it will try out different browsers and see if they are installed in the current system. If installed, run the test.
Related
I'm attempting to execute a TestCafe suite on locally installed Safari. I have previously executed the tests on chrome, chrome:headless, firefox, and firefox:headless. When running the command testcafe --list-browsers to retrieve my list of installed browsers, I receive the following:
testcafe --list-browsers
Using locally installed version of TestCafe.
firefox
chrome
safari
When I execute a simple test via command line, testcafe safari path/to/tests/, the Safari browser will launch, but no navigation takes place. I remain on the launch window (showing my favorites and recently visited pages).
When the same command is executed for a different browser (say, testcafe chrome path/to/tests/), the tests are executed in the local browser.
Am I missing something that is required to get Safari up and running with TestCafe? I'm using TestCafe version 1.6.1. I'm not seeing any additional setup mentioned on the TestCafe documentation...
I was able to resolve this issue by disabling all uses of TestCafe Browser Tools in System Preferences -> Security & Privacy -> Privacy -> Automation. On my subsequent execution, I was prompted to allow TestCafe Browser Tools for Safari. After accepting the prompt, the tests ran as expected.
I also had deleted my node_modules directory and reinstalled dependencies, although I'm skeptical if that helped.
Why does this sign Error: No tests to run. Either the test files contain no tests or the filter function is too restrictive. always come out, if I already do these tests in the TestCafe Studio and did not give an error?
Also, I follow the Pluralsight course, wrote the same code an make the same steps, but still doesn't work.
The TestCafe window pops out but closes automatically after finishing the loading.
Why should I do, or try?
All fixed, was a version misunderstanding... with TestCafe 0.3.0 work immediately. Run
npm install testcafe-blink-diff#0.3.0 to install that version.
Also, I wasn't paying attention, cause the code I need it was on JavaScript, and I was writing down in TypeScript.
For some reason, my google chrome version was a problem too, so I change
Browser: Chrome 75.0.3770 / Windows 10.0.0 to Chrome 76.0.3809 / Windows 10.0.0
I have installed casperjs and phantomjs on my windows machina via npm. However I get this issue.
C:\>casperjs sample.js
C:\>Unable to open file: sample.js
Unsafe JavaScript attempt to access frame with URL about:blank from frame
with URL file:///C:/Users/vini/AppData/Roaming/npm/node_modules/casperjs/bin/bootstrap.js.
Domains, protocols and ports must match.
This is a known issue with CasperJS and the 1.9.8 version of PhantomJS. It doesn't do anything and the errors are only printed during exit. They don't interfere with your script. There is a workaround and it was merged into master branch on GitHub, but it is not available as a release of CasperJS yet (latest is 1.1-beta3).
The easiest way to solve this is to downgrade to PhantomJS 1.9.7. Since you're using NPM it is easily done with
npm -g install phantomjs#1.9.7-15
The PhantomJS versions match with the NPM phantomjs package versions up until 1.9.7, then everything breaks. You can check the versions with npm show phantomjs.
If you downgrade to version 1.9.7, you will have to run with the --ssl-protocol=any commandline option for sites that request https resources. The reason is shown in my answer here.
The proper way to solve this is to install a new version from git. This will enable you to not only use PhantomJS 1.9.8 without the additional error lines, but also PhantomJS 2 which would not be possible with CasperJS 1.1-beta3.
References:
GitHub issue #1068
Workaround for CasperJS #1139
PhantomJS issue on SO
Use
"phantomjs": "^1.9.9"
And for caseperJs
casperjs --ssl-protocol=tlsv1 test run.js
I know I'll get crap for this but it's worth it if someone can help.
I can't find a guide, tutorial, or instructions anywhere for installing web driver on a windows machine. I've got a site running on a homestead vagrant box and need a way of running acceptance tests locally. I had tests setup using PhpBrowser but those don't simulate JavaScript. If anyone knows of a guide to do this or a better way to run acceptance tests it would help immensely. I've got Ajax calls so PhpBrowser and resources like it won't work.
Thanks!
Just download the selenium webserver the jar file and run it in a command shell with java -jar selenium-server-standalone-2.43.1.jar. The selenium server will now listen on the default port 4444. If you run your test it should work as expected. Keep in mind that selenium webserver opens firefox and uses it for testing. It's pretty useful for watching the test cases.
If you want a headless test (no visible browser) you need to download phantomjs. Unpack it and run the phantomjs.exe with --webdriver=4444 as an argument (so phantomjs.exe --webdriver=4444).
Download and Run the selenium-server-standalone-2.43.1.jar as stated in the comment. I had to add firefox_binary: C:\Program Files (x86)\Mozilla Firefox\firefox.exe under capabilities: in my acceptance.suite.yml file. I also added it to the path variable but I'm not sure if that made a difference. Had to add the firefox_binary to make it work.
Here's my set up on Ubuntu
dalek and dalek-cli installed as instructed in the website, the version is displayed correctly
phantomjs was installed via npm install but the phantomjs command could not be run
installed phantomjs via apt-get ... now I have version 1.4
in the folder /var/www/first_tests/ I have the package.json file provided in the website along with a subfolder tests containing first.js with the google example provided
I am in my homedirectory since that's the only place I can call dalek (I'm guessing because that where I was when I installed it) so I'm doing
dalekjs /var/www/first_tests/tests/*.js
The console shows "Running tests" but nothing happens. Trying to run
phantomjs /var/www/first_tests/tests/first.js
gives me "undefined:0 ReferenceError: Can't find variable: module"
Dalek expects the PhantomJS binary in the:
node_modules/dalekjs/node_modules/dalek-browser-phantomjs/node_modules/phantomjs/bin
Folder. Also, it definitely needs version 1.9.0 or higher.
You could try to download the binary from the PhantomJS homepage & manually copy it to the folder mentioned above.
It would be awesome, if you could send me (dalekjs#asciidisco.com) the npm debug log,
so that I can check why this happened in the first place.