Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser-based testing tool which is not broken?

Sorry for the controversial title here!

I've done a fair bit of browser-based testing (of JS-heavy web pages), using Selenium and Selenium-based libraries like Capybara. It has always been a big pain in the neck to get the test suites to work consistently. Yes, I know that rather than inserting calls to sleep() here and there, you are supposed to wait for DOM elements to become visible, or meet other conditions, yadda yadda. That's all good, and it does help a bit. I'd think that I wasn't doing it quite right, if it was not for...

If it was not for the time, before I had ever written Selenium code myself, when the company I was consulting for hired a firm which specializes exclusively in writing Selenium test suites. They sent a guy who was supposedly an expert on Selenium, and he wrote a full test suite for our web app. Need I tell you what happened when we actually used the test suite?

I've concluded that the whole approach which tools like Selenium use is subject to a big race condition. You have a test process, and a separate browser process which talk over a socket. The test process sends queries to the browser to find out the state of the DOM, and as the browser continues running, computes what to do. Then it sends a separate message to the browser to simulate a click, or keystroke, etc.

If you have ever written multi-threaded programs, you know that just doesn't work. It's a "check-then-act" race. If the test process could freeze JS execution in the browser, query its state, issue simulated clicks/keystrokes, and then unfreeze the browser, then it would be OK. (Like using a lock to protect the critical section of a multi-threaded program.)

The only way I can think of getting around the race condition would be for each test case to be written in JS. That precludes test cases which span navigation across multiple pages, of course. You also need a way of resetting the page to a "clean" state at the beginning of each test case.

Does anyone know a tool/approach for testing in-browser JS "apps", which allows mortals like me to write test suites which run 100% consistently, without tearing out all my hair?

(PS. Another conclusion from experience with Selenium: A lot of free jQuery plugins have bugs which don't appear when humans are using the page, simply because they can't click as fast as Selenium can!)

like image 303
Alex D Avatar asked Jan 11 '14 20:01

Alex D


People also ask

Which tool is used for browser based testing?

Selenium In the list of open source automation testing tools for web applications This is the all time favorite tool of testers. Selenium is popularly known as one of the best regression testing tools that operate seamlessly over different browsers and platforms.

Which is the best tool for cross-browser testing?

Katalan Studio is among the most popular cross-browser testing tools. It is built on top of the open-source automation frameworks Selenium, Appium with a specialized IDE interface for web, API, mobile, and desktop application testing.

Which tool is best for performance testing?

Apache JMeter Apache JMeter helps you measure and analyze software performance. It's an open source tool based on Java that people use mainly for testing web app performance, but it also finds usage on other services. It can test performance for both dynamic and static resources, as well as dynamic web apps.

What type of testing is browser testing?

Cross-browser testing, also called browser testing, is a quality assurance (QA) process that checks whether a web-based application, site or page functions as intended for end users across multiple browsers and devices.


1 Answers

Have you seen casperjs, which can run on top of phantomjs (a headless webkit browser) or slimerjs (a headless gecko browser)?

The unit testing syntax is clean and friendly and it executes your tests in the context of the browser sequentially, using a method called evaluate().

like image 103
jedifans Avatar answered Sep 29 '22 23:09

jedifans