How do rapid test driven front end development - selenium

I'm trying to rapidly develop my frontend, but every time I change my code I find myself refreshing my browser and running some macro to test whether the changes in my code solved the problem.
I tried changing the process to headless PySelenium, but it takes so long for the driver to launch every time I change my code.
I also tried Cypress.io, but after following the tutorial, the directory just didn't load.
I'm looking for a headless option that runs as fast as possible.

Related

How to wait till all components are loaded in Cypress?

My Cypress test cases are working fine when I run from my system pointing to QA. But the scheduled builds from CI are failing randomly because sometimes the page is taking more time to load.
I've tried cy.wait(1500) -> It works sometimes and fails sometimes. So, I was wondering is there a command in cypress that waits till all components in the page is loaded. Instead of I try different values inside cy.wait() which in turn fails someday?
By default, Cypress has smart waits for all elements to load and the page to render. This section confirms that: https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Cypress-is-Not-Like-jQuery
Instead of inserting cy.wait() in each and every step (Best practice is to minimise the use of this), you can include a maximum timeout on your cypress.json file:
"defaultCommandTimeout": 30000,
"pageLoadTimeout": 60000,
"requestTimeout": 60000,
If it still fails, then something is wrong with your test environment and might be a good time for a dev to check its performance as you don't want an environment that loads that long especially if it is a replica of production / live site.

Execute Test Suite Without Refreshing Page in Selenium IDE

I'm trying to create a test case in Selenium IDE.
The idea is to split my whole test in smaller ones to help find problems in the execution.
Example of my test suite
I've created a test suite with all my small tests inside, and I'd like that the next test starts right where the last one stopped. But in the beginning of the execution, every test refreshes the browser.
Test Refreshing Browser on start of the execution
My question is:
Is it possible to run an entire test suite without refreshing the browser when a new test starts?
thanks a lot

Why phantomjs script is killed automatically in between script execution?

I am trying to do web scraping using phantomJs. I am doing recurring task in that script so same script runs around 10k times with different parameters in single execution. It would take around 3 hours to complete process.
The issue is, it suddenly stops at random point with killed status written on the screen.
I tried some of the tricks to solve it but nothing worked.
Like - Tried localStorage.clear() in page.evaluate() function,
Reinstalling Phantom Js
So I need to know why it is happening and what can I do to fix it.

Application going down

I am trying to run a selenium script and the application also runs fine. But in some case all a sudden application goes down and this can happens at any stage of run the script.
So how to handle this because if Application goes down An Error page opens up and in script i may be trying to click a button or verifying something which doesn't happen and throws a exception.
Looks like its an application issue. You need to report the issue. Also it looks like you need to improve your infrastructure so that your application can run smoothly.
No recommaned: If you need to test it anyway, please add Thread.sleep(2000) after click() to make script execution slow.

Possible issue with running selenium tests on one machine concurrently

I have multiple similar sites (same layout, just different data), and each of them has drop down menu on mouse over (and disappears on mouse out).
I am using Selenium 2 and WebDriver, and I have one selenium test case that basically do the mouse over and make sure each of the link in the drop down menu works.
I am using selenium grid, so I have a hub and few test machines.
Because I have many sites (few hundred) to test, so I am thinking of making each machine to run the test case against multiple sites in parallel.
My concern is because there can be only one active browser at a time, will it cause issue if web driver tries to perform Action.moveToElement() on multiple browsers at roughly the same time? Will only the active browser performs Action.moveToElement() properly and other browsers fail? If there will be an issue, is there any workaround?
I have tried it using JUnitCore.runClasses(ParallelComputer.classes(), SomeClass1.class, SomeClass2.class, SomeClass3.class);, it decreased the passed tests percentage from 100% to about 67% when running three tests on a machine. Not good =/.
The good part - firefox actually can do it in parallel. If the FF instances are delayed between each other so they don't do the same thing at the same time, it works better. Some of the failures happened during a Firefox bootup - so if you can minimize closing and opening windows, do it. But still, sometimes it just fails for no reason.
If you really would use the saved time, then go for it, log all failed tests and run them again after the first round - this time one at a time.
You could also solve this, depending on your ultimate goal of testing, by not using the Action class with the mouse-movement click, but instead use the WebDriver findBy-click method or Javascript executor method. It would probably be less contentious when running multiple windows at the same time. If the Action class, when defining a mouse movement, uses native calls at all, such as "move to Point", then one browser over the top of another, then I would guess it's possible that the movement point could be masked by another window. I am really not sure about this, just giving you another idea to try.