Cypress run command without re-running test - console

Just wondering, say I have a lengthy cypress test that has finished running. Is there a way to try out a new cypress command, say something like
cy.get('.tg-tag').should('have.css', 'background-color', 'rgb(0, 128, 0)')
Thanks much!

There is the cy.now() internal command that allows the user to run a cypress command via dev tools in the test runner. Gleb has a general example here and a more detailed example here. The Cypress docs has a small example here.
There are also a few discussion on cypress github found below with examples of usage:
Support REPL #8195
test commands in the Chrome DevTools console #6080
You'll have to play around with your specific situation, but once your test has completed, open your dev tools and use the following format:
// cy.now(commandName, arguments…)
cy.now('visit', '/') // visit root
cy.now('contains', 'button', 'Sign in')

If you mean you want to use a kind of interactive mode for new/additional commands, there's the experimental Cypress Studio mode.
It's not free text, but you can add the expression you indicated, best described in the PR

Related

Is there a way to set breakpoints in Cypress tests?

Like the title says. I've recently gotten a hold of a Cypress codebase that I need to convert into Playwright. I'm new to both Cypress and Playwright but have experience using other automated testing systems. The last one I used made it pretty easy to set breakpoints on any line that would let me step through the code and see what each line was doing. I figured if I could do this, it would make my deciphering of the Cypress code so I could turn it into something that works with Playwright an easier prospect. Google has not been the most helpful here.
You can use Cypress' debugger to achieve something similar to setting breakpoints while executing via cypress open.
cy.get('foo').debug();
If you prefer VSCode, there is a similar SO question. It seems it require some manual setup to get debugger to work.
For IntelliJ (IDEA, WebStorm etc.), there is a paid Cypress Support Pro plugin (I'm the author). It fully integrates the IDE debugger with Cypress. See this video overview.

Which version of the Selenium firefox web driver is recommended?

Apologies if I've gotten the terminology wrong. I'm following the vignette on R selenium to the letter, and so I'm using version 2.53.1 of the standalone firefox web driver in docker:
docker run -d -p 5901:5900 -p 127.0.0.1:4445:4444 --link http-server selenium/standalone-firefox-debug:2.53.1
I'm playing around trying to fetch my student data automatically from my university, and so far I've managed to choose the correct university from a list, logging in with my username/password and clicking the "my education" button. Here I get stuck. It doesn't matter if I click the link in the debug tool (that would be tightVNC Viewer) or if I tell the script which links should be clicked. I end up with an empty page with just the word "filter" on it:
This doesn't seem to happen when I use regular firefox:
Also, for some reason the first page is in English why the second is not.
Since the issue remains the same regardless if I use commands or the debug tool the issue might be the web driver I think. Should I still be using version 2.53.1 or is there a newer, better version out there?
Which one in that case?
If I'm on the wrong track and the problem is something else entirely then please tell me so!

Starting Meteor with Velocity test without the Chrome pop-up

In my quest to gather knowledge about how to use Velocity, I ran across a snippet that mentioned a shell variable to set the browser Velocity used to run Karma in PhantomJS as apposed to creating a Chrome window pop-up each time I run my app in DEV-mode. At the time I shrugged it off, but after having implemented some testing in two of my apps, I can say it's an annoying pain to have the tests running in a pop-up window.
Does someone know if how one might get the tests running such that they run in PhantomJS and not in a Chrome pop-up windows? I thought the variable was something like VELOCITY_BROWSER=PhantomJS, but that doesn't seem to work. Also, is there a way to setup Meteor so that it simply sets this as a default so I don't have to create the variable each time, like in a config or something?
I found the answer for those that find this and were also wondering how to prevent the Karma popup.
I am using the sanjo:jasmine test suite, which uses Karma for the client integration tests. You can set the default browser to PhantomJS by simply adding this to your environment when you run meteor:
JASMINE_BROWSER=PhantomJS
Or, if you just want to turn off client integration tests altogether simply adding this:
JASMINE_CLIENT_UNIT=0
So, for instance you can run your app like JASMINE_BROWSER=PhantomJS meteor, and you will not get the popup any longer. What I did was created a meteor.sh in my app root folder that I use to launch with environment variables like so:
#!/bin/sh
JASMINE_BROWSER=PhantomJS meteor
This is only for convenience so I wouldn't have to remember the variable to do this. This should work on any *nix-based OS. You could also make an alias if you wanted. It would look something like:
alias meteor=JASMINE_BROWSER=PhantomJS meteor
I may be slightly off in the syntax, but I think that should work.
To use PhantomJS you do need to have it installed, so run this in a terminal:
npm install -g phantomjs
Or, if you are on a Mac run (you will need brew installed):
brew install phantomjs
Hope this helps someone in the future.
In sanjo:jasmine 0.17.0 on Windows, PhantomJS has some issues with meteor's autoupdate feature. You may have problems with re-running tests when you change the app's code.
If you'd like to stick with Chrome window, it can be somewhat hid by using chrome's commandline options, but you'd need to update karma-chrome-launcher\index.js to include these:
return [
'--user-data-dir=' + this._tempDir,
'--no-default-browser-check',
'--no-first-run',
'--disable-default-apps',
'--disable-popup-blocking',
'--disable-translate',
'--window-position=-800,0', // <-- added
'--window-size=800,600' // <-- added
].concat(flags, [url])
The window will show up, but will be created off-screen, and somehow luckily doesn't even steal the keyboard focus.

What are the click button and link command for PHPUnit Selenium?

I am writing test with the selenium and I export to phpunit.
But click command doesn't work for me. I am writing like that $this->click("css=input.login");. But it shows errors like that ERROR: Command execution failure. And I already tested mine element correct or not.
I can find it from this. And the answer is the following.
This might also be related to a Selenium bug with the recent Firefox release (FF 22 I think), see (will be fixed in Selenium 2.34).
See Details in here.

Jmeter console manipulation for automation purposes

I am pretty newbie by this question.
I want to know about possibilities of how to manipulate Jmeter through the console (bash or cmd).
My goal for a start consists in understanding of how to run my testplan.jmx for several URLS. For this I add "server" and "port" parameters into my testplan.
How could I can change these parameters through the console and then run Jmeter ?
Morover, I want to ask you guys to suggest any free online tutorials where I can learn more about "Jmeter in non gui mode" and possibilities for integration Jmeter between different frameworks to use for automated testing.
Thank you very much indeed.
See:
http://jmeter.512774.n5.nabble.com/How-to-Run-Jmeter-in-command-line-td2640725.html
You can launch your test plan from the command line, specifying parameters, like:
jmeter -n -t plan.jmx -Jmy_url=http://www.firsturl.com
Inside your testplan you'd reference that command line param as ${__P(my_url)}
In terms of capturing results when running in non-gui mode, you may want to see:
http://blogs.amd.com/developer/2009/03/31/using-apache-jmeter-in-non-gui-mode/
Personally, my experience is with using the GUI and writing and running test plans that way but this seems workable.

Resources