Giter Site home page Giter Site logo

huxley's Introduction

Huxley

Watches you browse, takes screenshots, tells you when they change

Huxley is a test-like system for catching visual regressions in Web applications. It was built by Pete Hunt with input from Maykel Loomans at Instagram.

Archived Repo

This is an archived project and is no longer supported or updated by Facebook or Instagram. Please do not file issues or pull-requests against this repo. If you wish to continue to develop this code yourself, we recommend you fork it.

What is the problem?

  • UI tests are hard to write and are usually fragile.
  • Automated testing can't tell you if something doesn't look right, so UI regressions may go undetected.
  • It can be difficult for designers to participate in the code review process even though reviewing the way the UI looks is just as important as reviewing the code that creates it.

How does Huxley help me?

Huxley runs in two modes:

Record mode

Using Selenium WebDriver, Huxley opens a page and records your actions. When you press enter in the Huxley terminal, Huxley will save a screenshot.

Testing a new flow is as simple as manually testing it once. Huxley will remember and re-run your "manual" test plan for you automatically.

Playback mode

You should run Huxley in playback mode before submitting code for review and in continuous integration. Huxley will open the page and re-run your actions with WebDriver. It will take screenshots and compare them with the original screenshots. If they have changed, it will save the new screenshots and warn you that they have changed.

When screenshots have changed, those screenshot changes will show up in your commit. A designer can review them to be sure they're OK. And your continuous integration system can alert you if you forgot to run Huxley.

By default, Huxley will overwrite the old screenshots with new ones. That means you don't have to rewrite anything when your UI changes like you would with a traditional WebDriver test -- Huxley will just take a new screenshot for you and when it's checked in your test is updated!

Installation

pip install huxley

Tutorial

In examples/ you'll find two simple completed Huxley tests. To start from scratch, simply remove toggle.huxley, type.huxley and Huxleyfile.

Motivation

In examples/webroot/toggle.html you'll find a very simple JavaScript application that implements a toggle button. The goal of Huxley is to make creating an integration for this component effortless, and to make it easy to update the test when the UI changes.

Step 1: host your app somewhere

For our example, simply cd to examples/webroot and run python -m SimpleHTTPServer to start a basic server for our demo. In your app you may need to start up whatever framework you're using.

Step 2: create a Huxleyfile

A Huxleyfile describes your test. Create one that looks like this:

[toggle]
url=http://localhost:8000/toggle.html

This creates a test named toggle that tests the URL http://localhost:8000/toggle.html.

Step 2: record the test

Huxley makes writing tests easy because it simply records your browser session -- specifically mouse clicks and key presses on a single page -- and can replay them in an automated way. To do this you need to install Selenium Server and start it. It's as easy as java -jar selenium-server-standalone-XXX.jar.

Then, run Huxley in record mode: huxley --record. Huxley will bring up a browser using Selenium. Press enter in the Huxley console to take a screen shot of the initial page load. Then toggle the button in the browser a few times. After every click, switch back to the Huxley console to take a screen shot. When you've tested all of the functionality you want to test, simply type q and then enter in the Huxley console to exit.

After confirming, Huxley will automatically record the test for you and save it to disk as toggle.huxley. Be sure to commit the Huxleyfile as well as toggle.huxley into your repository so you can track changes to them.

Step 3: playback

Simply run the huxley command in the same directory as the Huxleyfile to be sure that your app still works.

Step 4: update the test with new screen shots

You'll likely update the UI of the component a lot without changing its core functionality. Huxley can take new screen shots for you when this happens. Tweak the UI of the component in toggle.html somehow (maybe change the button color or something) and re-run huxley. It will warn you that the UI has changed and will automatically write new screen shots for you. If you run huxley again, the test will pass since the screen shots were updated.

The best part is, since the screen shots are checked into the repository, you can review the changes to the UI as part of the code review process if you'd like. At Instagram we have frontend engineers reviewing the JavaScript and designers reviewing the screenshots to ensure that they're pixel perfect.

Step 5: run in CI mode

If you're using a continuous integration solution like Jenkins you probably don't want to automatically rerecord screen shots on failure. Simply run huxley --playback-only to do this.

Additionally, you may find that you're dissatisfied with Huxley replaying your browsing session in real-time. You can speed it up (or slow it down) by editing your Huxleyfile to read:

[toggle]
url=http://localhost:8000/toggle.html
sleepfactor=0.5

This edit should cut the execution time in half.

Best practices

Integration tests sometimes get a bad rap for testing too much at once. We've found that if you use integration tests correctly they can be just as effective and accurate as unit tests. Simply follow a few best practices:

  • Don't test a live app. Use mocking to make your components reliable instead. If you hit your live app, failures in any number of places could trigger false failures in your UI tests. Instead of hitting a real URL in your app, create a dedicated test URL for Huxley to hit that uses mocking (and perhaps dependency injection) to isolate your UI component as much as possible. Huxley is completely unopinionated; use whatever tools you want to do this.
  • Test a small unit of functionality. You should try to isolate your UI into modular components and test each one individually. Additionally, try to test one interaction per Huxley test so that when it fails, it's easy to tell exactly which interaction is problematic and it's faster to re-run it.

Technical FAQ

Why does Huxley stop recording when I navigate away from the page?

Huxley is designed for testing JavaScript UI components at this time. We've found that you can test multiple pages by creating a new Huxley test for each URL. This is valuable even if you don't use the interactive features of Huxley because it will ensure your static pages stay pixel perfect.

I can't tell what changed!

It's usually best if you use an image comparison tool like Kaleidoscope to tell what changed. But Huxley includes a simple image diff tool; simply run huxley with the --save-diff option to output a diff.png which will show you the pixels that changed.

How do I use a remote webdriver server?

You can set the HUXLEY_WEBDRIVER_LOCAL environment variable to tell Huxley which webdriver URL to use for --record mode. You can set the HUXLEY_WEBDRIVER_REMOTE environment variable to tell Huxley which webdriver URL to use for screenshots and playback. Usually you only need to use this when working in a team setting such that everyone's screenshots are taken on the same machine configuration (otherwise they'll change depending on who ran them last).

Can I test responsive design?

Of course! Simply add a screensize setting to your Huxleyfile. The default is screensize=1024x768.

Philosophical FAQ

Why would you use this instead of unit testing?

First of all, if you sufficiently componentize your UI, Huxley can be used as a unit testing tool.

With that said, unit tests have two shortcomings today.

  • They usually take a long time to write. Instagram on the web had a single engineer and a designer working on a ton of things in parallel, and we didn't have time to write beautifully isolated tests with elegant dependency injection and comprehensive assertions. We just had to make sure that we didn't cause bugs when we were frantically shipping code. A lot of small web teams can probably identify with this.
  • They do not test the look of the UI. Huxley does pixel-by-pixel comparisons of the UI. Traditional UI test systems inspect the DOM but do not look at how it actually renders. We once had a bug where a CSS rule made the height of all image components 0px; without a pixel-by-pixel comparison it's unlikely we would have ever written an explicit test for this.

What's the best way to use Huxley?

Use it however you want! But we generally shell out to it from within an existing test runner (i.e. Django or Rails). This lets us programmatically start a test server for Huxley to hit.

If you're using Python, you can use Huxley directly in a test (see huxley.integration.HuxleyTestCase) or browse the source to see its core APIs.

If you're on a team I recommend setting up webdriver on a shared server and changing the HUXLEY_WEBDRIVER_REMOTE environment variable such that everyone's screenshots are pixel perfect (see the technical FAQ above).

Why is it called Huxley?

Lots of test frameworks and methodologies are very opinionated about how your code should be structured or how you should write tests. Some tools are so opinionated that they're almost religious about their view of testing! We wanted a tool that got out of our way and let us fight regressions as quickly and easily as possible without being opinionated about it. So we named it after the guy who coined the term "agnostic", Thomas Henry Huxley.

huxley's People

Contributors

10io avatar chenglou avatar emanlove avatar jacobangel avatar jamesgpearce avatar maxlinc avatar petehunt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

huxley's Issues

cannot install huxley

When running setup.py with Python 3.4, gives error "NameError: name 'execfile' is not defined"
With Python 2.7, gives error "ImportError: No module named setuptools"

how am I supposed to install huxley?

Test a website page that requires authentication

Hi!

We are trying to test our website page that requires us to login first. However huxley fails to record a session in this case because we visited two pages during the session, i.e the login page and the actual that we wanted to test.

Do you have any ideas on how to test such website with huxley. Also, is it possible to use huxley in our existing ruby on rails application.

Thanks,
Rajat & Keith

Traceback on diff

Don't know if it's expected behavior but every time I get a diff huxley gives me a traceback and quits. I have included the output from the example recipe:

$ huxley
-------------------------------
Running Huxley file: Huxleyfile
-------------------------------
Running test: toggle
Running test to determine if we need to rerecord
Begin playback
  Sleeping for 2619.0 ms
  Taking screenshot 0
Test failed, rerecording...
Begin rerecord
  Sleeping for 2619.0 ms
  Taking screenshot 0
  Sleeping for 2245.0 ms
  Clicking [116, 79]
  Sleeping for 1355.0 ms
  Taking screenshot 1
  Sleeping for 2365.0 ms
  Clicking [121, 70]
  Sleeping for 1857.0 ms
  Taking screenshot 2

Playing back to ensure the test is correct

Begin playback
  Sleeping for 2619.0 ms
  Taking screenshot 0
Traceback (most recent call last):
  File "/usr/local/bin/huxley", line 9, in <module>
    load_entry_point('Huxley==0.3', 'console_scripts', 'huxley')()
  File "/usr/local/lib/python2.7/site-packages/huxley/cmdline.py", line 150, in main
    sys.exit(plac.call(_main))
  File "/usr/local/lib/python2.7/site-packages/plac_core.py", line 309, in call
    cmd, result = parser_from(obj).consume(arglist)
  File "/usr/local/lib/python2.7/site-packages/plac_core.py", line 195, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/usr/local/lib/python2.7/site-packages/huxley/cmdline.py", line 138, in _main
    screensize=screensize
  File "/usr/local/lib/python2.7/site-packages/huxley/main.py", line 129, in main
    TestRun.rerecord(test, filename, (url, postdata), d, sleepfactor, diffcolor, save_diff)
  File "/usr/local/lib/python2.7/site-packages/huxley/run.py", line 79, in rerecord
    cls.playback(test, path, url, d, sleepfactor, diffcolor, save_diff)
  File "/usr/local/lib/python2.7/site-packages/huxley/run.py", line 85, in playback
    run._playback(sleepfactor)
  File "/usr/local/lib/python2.7/site-packages/huxley/run.py", line 95, in _playback
    step.execute(self)
  File "/usr/local/lib/python2.7/site-packages/huxley/steps.py", line 94, in execute
    raise TestError('Screenshot %s was different.' % self.index)
huxley.errors.TestError: Screenshot 0 was different.

Selenium can't detect buttons in modal panels

Hi,

I'm using the Twitter Bootstrap framework to display a simple modal panel with a button in it. Huxley is able to record the test case where I open the modal, then click on the button. However, during playback, it spits this error out (which is from Selenium):

Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element is not currently visible and so may not be interacted with
Build info: version: '2.34.0', revision: '11cd0ef', time: '2013-08-06 17:10:22'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.4', java.version: '1.6.0_51'
Driver info: driver.version: unknown
    at <anonymous class>.fxdriver.preconditions.visible(file:///var/folders/1c/c828yyp916x8cxzgntwnt5fm0000gn/T/anonymous4476072821512445183webdriver-profile/extensions/[email protected]/components/command_processor.js:8230)
    at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///var/folders/1c/c828yyp916x8cxzgntwnt5fm0000gn/T/anonymous4476072821512445183webdriver-profile/extensions/[email protected]/components/command_processor.js:10799)
    at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///var/folders/1c/c828yyp916x8cxzgntwnt5fm0000gn/T/anonymous4476072821512445183webdriver-profile/extensions/[email protected]/components/command_processor.js:10816)
    at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///var/folders/1c/c828yyp916x8cxzgntwnt5fm0000gn/T/anonymous4476072821512445183webdriver-profile/extensions/[email protected]/components/command_processor.js:10821)
    at <anonymous class>.DelayedCommand.prototype.execute/<(file:///var/folders/1c/c828yyp916x8cxzgntwnt5fm0000gn/T/anonymous4476072821512445183webdriver-profile/extensions/[email protected]/components/command_processor.js:10763)
17:40:07.625 WARN - Exception: Element is not currently visible and so may not be interacted with

Doing a bit of investigation, looks like it might be an issues with the Selenium FF driver, This might be related:

http://stackoverflow.com/questions/17602334/element-is-not-currently-visible-and-so-may-not-be-interacted-with-but-another

Any idea how to resolve this?

Rob

Entire page ScreenShots

Im trying to implement Huxley as way to test css regression, using the project Styleguide as the canonical source where the tests happen.

Although i get the idea of single function testing, most tests require a full page screenshot, instead of just a small portion.

Any way I can do that?

Do we want pixel perfect matches?

Like this idea a lot...

Is there a way to perform some form of "fuzzy" compare?

Imagine I've just changed a color in my app and now all tests have to be recreated because the Hux strats tripping over each and every reference screenshot?

. D

Playback error when reloading a page

Hi,

I have a page with a button, when user presses it, it makes a backend AJAX call, then refreshes the page on success. I want to record the before and after, however, the following error came up:

huxley.errors.TestError: Could not call window._getHuxleyEvents(). This usually means you navigated to a new page, which is currently unsupported.

I understand why it's happening, but is it possible for huxley to navigate between pages, and continue recording?

Rob

No Huxleyfile found

I created a Huxleyfile like at tutorial and execute following command huxley --record but take No Huxleyfile found error. It is probably basic mistake but i can't understand. By the way my Huxleyfile at examples/ directory.

just tried to install it on windows

pip install huxley
...

File "build\bdist.win32\egg\setuptools\command\egg_info.py", line 369, in add_
defaults

File "build\bdist.win32\egg\setuptools\command\sdist.py", line 296, in read_ma
nifest

File "build\bdist.win32\egg\setuptools\command\egg_info.py", line 284, in appe
nd

File "c:\Python27\lib\distutils\util.py", line 124, in convert_path

raise ValueError, "path '%s' cannot be absolute" % pathname

ValueError: path '/' cannot be absolute


TestError: Screenshot 0 was different.

One particular error keeps getting returned when I record and run the Huxley tests, on particular pages only. This error has been found before and the solution was unclear (#27).

Here's an example of the error returned on such pages:


NathanMBA:test nathan$ huxley  --record
--------------------------------------
Running Huxley file: HuxleyfileCurrent
--------------------------------------
[UTIL02-0_FAQs.html] Running test: UTIL02-0_FAQs.html
Begin record
Press enter to take a screenshot, or type Q+enter if you're done

1 screenshots taken
Press enter to take a screenshot, or type Q+enter if you're done
q

Up next, we'll re-run your actions to generate screenshots to ensure they are pixel-perfect when running automated. Press enter to start.

Begin rerecord
  Sleeping for 1395.0 ms
  Clicking [726, 285]
  Sleeping for 2284.0 ms
  Taking screenshot 0

Playing back to ensure the test is correct

Begin playback
  Sleeping for 1395.0 ms
  Clicking [726, 285]
  Sleeping for 2284.0 ms
  Taking screenshot 0
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 808, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 761, in run
    self.__target(*self.__args, **self.__kwargs)
  File "build/bdist.macosx-10.9-intel/egg/huxley/threadpool.py", line 32, in >thread
    func(*args, **kwargs)
  File "build/bdist.macosx-10.9-intel/egg/huxley/cmdline.py", line 69, in >run_test
    screensize=screensize
  File "build/bdist.macosx-10.9-intel/egg/huxley/main.py", line 110, in main
    TestRun.record(local_d, d, (url, postdata), screensize, filename, >diffcolor, sleepfactor, save_diff)
  File "build/bdist.macosx-10.9-intel/egg/huxley/run.py", line 152, in record
    cls.rerecord(test, path, url, remote_d, sleepfactor, diffcolor, save_diff)
  File "build/bdist.macosx-10.9-intel/egg/huxley/run.py", line 79, in rerecord
    cls.playback(test, path, url, d, sleepfactor, diffcolor, save_diff)
  File "build/bdist.macosx-10.9-intel/egg/huxley/run.py", line 85, in playback
    run._playback(sleepfactor)
  File "build/bdist.macosx-10.9-intel/egg/huxley/run.py", line 95, in _playback
    step.execute(self)
  File "build/bdist.macosx-10.9-intel/egg/huxley/steps.py", line 103, in >execute

   raise TestError('Screenshot %s was different.' % self.index)

TestError: Screenshot 0 was different.

The page has no animation or anything on it that would cause the screenshot to be different.

After taken screenshots q+enter exit huxley report error and record.json file is empty

Exception in thread Thread-1:
Traceback (most recent call last):
File "E:\Python27\lib\threading.py", line 810, in **bootstrap_inner
self.run()
File "E:\Python27\lib\threading.py", line 763, in run
self.__target(_self.__args, _self.__kwargs)
File "build\bdist.win-amd64\egg\huxley\threadpool.py", line 32, in thread
func(_args, _kwargs)
File "build\bdist.win-amd64\egg\huxley\cmdline.py", line 69, in run_test
screensize=screensize
File "build\bdist.win-amd64\egg\huxley\main.py", line 137, in main
return 0
File "E:\Python27\lib\contextlib.py", line 154, in __exit

self.thing.close()
File "E:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriv
er\remote\webdriver.py", line 445, in close
self.execute(Command.CLOSE)
File "E:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriv
er\remote\webdriver.py", line 165, in execute
self.error_handler.check_response(response)
File "E:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriv
er\remote\errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: u"Error communicating with the remote browser. It m
ay have died.\nBuild info: version: '2.39.0', revision: 'ff23eac', time: '2013-1
2-16 16:11:15'\nSystem info: host: 'hugoxie-PC0', ip: '10.33.64.52', os.name: 'W
indows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'\nDriver
info: driver.version: EventFiringWebDriver" ; Stacktrace:

Problems in 10.9 Mavericks

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found

#       include <X11/Xlib.h>

                ^

1 error generated.

error: command 'cc' failed with exit status 1

Record new tests without re-recording old ones

Is there a way to record a new test without re-recording old ones?

If I add a test to Huxleyfile.json, it seems like I have to re-record all of the tests.

I have been working around this by:

  • duplicating the existing test folders
  • hux -r
  • press enter to skip tests I've already recorded
  • record the new test(s)
  • delete the folders for tests I skipped
  • replacing the folders for tests that were already recorded

Is there a huxlified way to do this?

Huxley execution no working on Mac

Hi,

Having the toggle app running, I executed the the following Huxley command and I get the following output.

[me@localhost]$ huxley --playback

Running Huxley file: Huxleyfile

[toggle] Running test: toggle
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in **bootstrap_inner
self.run()
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(_self.__args, _self.__kwargs)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/huxley/threadpool.py", line 32, in thread
func(_args, _kwargs)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/huxley/cmdline.py", line 81, in run_test
screensize=screensize
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/huxley/main.py", line 83, in main
d = webdriver.Remote(remote, CAPABILITIES[browser])
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 72, in __init

self.start_session(desired_capabilities, browser_profile)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 114, in start_session
'desiredCapabilities': desired_capabilities,
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
self.error_handler.check_response(response)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: None ; Stacktrace:

Any ideas why Huxley is not working?

crash on startup

I am in the examples directory and huxley crashes. Just installed it.
localhost:examples kb1$ huxley --record
Traceback (most recent call last):
File "/usr/local/bin/huxley", line 5, in
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2607, in
parse_requirements(requires), Environment()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: jsonpickle==0.4.0
localhost:examples kb1$

no diff / empty record.json if initial screenshots differ

I am trying to make a test for a chart widget which seems to render slightly different each time. I was hoping running huxley with with --record and --save-diff would save the diff between the rerecorded and the second run screenshot, but it doesn't. And the record.json is empty so I have to record my getting to the unstable chart again.

I understand I have to create a test page for just that one chart and test only that, so I won't need a complicated interaction to get to it, but wouldn't it be nice to have the diffs/record.json saved anyway?

Missing dependencies for `pip install huxley`

pip install huxley failed, so I had to run the following individually:

$ pip install jsonpickle
$ pip install plac
$ pip install selenium
$ pip install pil

Finally, I could run:

$ pip install huxley

Want me to add this to the README?

UnicodeEncodeError on re-recording the Test

On re-recording the test, I getting the below error which results in a blank record.json file

print ' Typing', self.key
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 0: ordinal not in range(128)

[Full Trace:

Exception in thread Thread-1:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 808, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 761, in run
self.__target(_self.__args, *_self.__kwargs)
File "/Library/Python/2.7/site-packages/huxley/threadpool.py", line 32, in thread
func(_args, *_kwargs)
File "/Library/Python/2.7/site-packages/huxley/cmdline.py", line 69, in run_test
screensize=screensize
File "/Library/Python/2.7/site-packages/huxley/main.py", line 110, in main
TestRun.record(local_d, d, (url, postdata), screensize, filename, diffcolor, sleepfactor, save_diff)
File "/Library/Python/2.7/site-packages/huxley/run.py", line 152, in record
cls.rerecord(test, path, url, remote_d, sleepfactor, diffcolor, save_diff)
File "/Library/Python/2.7/site-packages/huxley/run.py", line 75, in rerecord
run._playback(sleepfactor)
File "/Library/Python/2.7/site-packages/huxley/run.py", line 95, in _playback
step.execute(self)
File "/Library/Python/2.7/site-packages/huxley/steps.py", line 61, in execute
print ' Typing', self.key
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 0: ordinal not in range(128)
]

Using Huxley on Pages with dynamic content

More of a question here, can't seem to find much info around or a forum for discussion so thought i'd ask it here.

Is there suggestions on how to setup huxley to run thorough CI on pages that are not static ? I have an issue where the test servers do not necessarily have the same database setup as the development environment, so there are regularly widgets that will not be in sync showing different data.

Would like to hear of ways people have been getting around this issue

Access error (last.png)

I tryed to use huxley on windows.

It successfully open firefox browser, take a screenshot. When I enter Q+Enter it start re-run my actions. It succesfully rerecord, but when it start the playback, huxley crashing with next error:

Traceback (most recent call last):                                                                      
  File "C:\Users\Plokhov\Envs\test\Scripts\huxley-script.py", line 9, in <module>                
    load_entry_point('Huxley==0.3', 'console_scripts', 'huxley')()                                      
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\huxley\cmdline.py", line 150, in main       
    sys.exit(plac.call(_main))                                                                          
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\plac_core.py", line 309, in call            
    cmd, result = parser_from(obj).consume(arglist)                                                     
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\plac_core.py", line 195, in consume         
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)                                      
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\huxley\cmdline.py", line 127, in _main      
    screensize=screensize                                                                               
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\huxley\main.py", line 109, in main          
    TestRun.record(local_d, d, (url, postdata), screensize, filename, diffcolor, sleepfactor, save_diff)
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\huxley\run.py", line 152, in record         
    cls.rerecord(test, path, url, remote_d, sleepfactor, diffcolor, save_diff)                          
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\huxley\run.py", line 79, in rerecord        
    cls.playback(test, path, url, d, sleepfactor, diffcolor, save_diff)                                 
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\huxley\run.py", line 85, in playback        
    run._playback(sleepfactor)                                                                          
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\huxley\run.py", line 95, in _playback       
    step.execute(self)                                                                                  
  File "C:\Users\Plokhov\Envs\test\Lib\site-packages\huxley\steps.py", line 97, in execute       
    os.unlink(new)                                                                                 
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'index.huxley\\last.png'

About stealing browser focus

Is the current focus stealing strategy is limited to --record? I see the actual screen shots are taken from a window behind the one in which I operated, as to remove input focus, etc. But when running in any other mode no such focus stealing is being done, which makes the screenshots taken during recording useless since they'll always be different than one the taken by those other modes.

Install huxley on Win7 NameError: name 'execfile' is not defined

Win7 Pro Python34 - I am getting: NameError: name 'execfile' is not defined
note: also tried with Python 27 but it didn't have pip

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Al

C:\Users\Z003BXMW>pip install huxley
Downloading/unpacking huxley
Downloading Huxley-0.5.tar.gz
Running setup.py (path:C:\Users\Z003BXMW\Ap
Traceback (most recent call last):
File "", line 17, in
File "C:\Users\Z003BXMW\AppData\Local\T
execfile(os.path.join(DIRNAME, 'huxle
NameError: name 'execfile' is not defined
Complete output from command python setup
Traceback (most recent call last):

File "", line 17, in

File "C:\Users\Z003BXMW\AppData\Local\Temp\

execfile(os.path.join(DIRNAME, 'huxley',
NameError: name 'execfile' is not defined

Huxley execution not working on Mac

Hi,

Having the toggle app running, I executed the the following Huxley command and I get the following output.

[will@Rebecas-MacBook-Air examples (master ✗)]$ huxley --playback

Running Huxley file: Huxleyfile

[toggle] Running test: toggle
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in **bootstrap_inner
self.run()
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(_self.__args, _self.__kwargs)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/huxley/threadpool.py", line 32, in thread
func(_args, _kwargs)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/huxley/cmdline.py", line 81, in run_test
screensize=screensize
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/huxley/main.py", line 83, in main
d = webdriver.Remote(remote, CAPABILITIES[browser])
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 72, in __init

self.start_session(desired_capabilities, browser_profile)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 114, in start_session
'desiredCapabilities': desired_capabilities,
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
self.error_handler.check_response(response)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: None ; Stacktrace:

Any ideas why Huxley is not working?

Huxley failing immediately after --record (on a test app) and on any running of tests in example app

I am trying to get Huxley up and running so I can evaluate it, and see if it fits my needs. Unfortunately I can't.

I installed Huxley, pip install huxley.

I did have to install all the dependencies manually, pip install jsonpickle, pip install plac, pip install selenium, pip install PIL.

Example App

I navigate to /examples/webroot/ and fire up the example app, python -m SimpleHTTPServer.

When I run the tests, huxley, I get the following:

Fail 1 Gist

Test App

My Huxleyfile looks like this;

[index]
url=http://localhost:3000/

I navigate to my test app's huxley directory, and try and record, huxley --record.

First, I get 2 Firefox windows that open;

screen shot 2013-09-16 at 4 14 47 pm

After I have clicked around, and made my screen shots, when huxley begins re-running my actions, the empty window closes;

screen shot 2013-09-16 at 4 15 11 pm

Then the whole thing fails;

Fail 2 Gist

I really love the idea of Huxley, and want to use it, but this is keeping me from evaluating it. Any thoughts?

Improve the `window._getHuxleyEvents is not a function` exception

I am trying to get Huxley to work on a simple login flow where I enter the username/password and the page redirects to a different url after login. While I can capture the screenshots, when I hit q+enter I get the below error. Can I use huxley to test scenarios like these?

Note that Huxley works otherwise when I am testing a single page like the toggle example included.

Press enter to take a screenshot, or type Q+enter if you're done
q
Traceback (most recent call last):
  File "/usr/local/bin/huxley", line 9, in <module>
    load_entry_point('Huxley==0.2', 'console_scripts', 'huxley')()
  File "/usr/local/lib/python2.7/dist-packages/huxley/cmdline.py", line 126, in main
    sys.exit(plac.call(_main))
  File "/usr/local/lib/python2.7/dist-packages/plac_core.py", line 309, in call
    cmd, result = parser_from(obj).consume(arglist)
  File "/usr/local/lib/python2.7/dist-packages/plac_core.py", line 195, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/huxley/cmdline.py", line 105, in _main
    record=True
  File "/usr/local/lib/python2.7/dist-packages/huxley/main.py", line 109, in main
    TestRun.record(local_d, d, (url, postdata), screensize, filename, diffcolor, sleepfactor, save_diff)
  File "/usr/local/lib/python2.7/dist-packages/huxley/run.py", line 127, in record
    events = d.execute_script('return window._getHuxleyEvents();')
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 397, in execute_script
    {'script': script, 'args':converted_args})['value']
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 152, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: u"window._getHuxleyEvents is not a function\nBuild info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:32:38'\nSystem info: os.name: 'Linux', os.arch: 'i386', os.version: '3.5.0-36-generic', java.version: '1.7.0_25'\nDriver info: driver.version: unknown" ; Screenshot: available via screen ; Stacktrace: Method anonymous threw an error in http://localhost:8000/<redirected-url>

Huxley record session fails with null exception

I'm having a problem when attempting to start a fresh record with Huxley. The exception error returned is below:

------------------------------------
Running Huxley file: huxtestfile.txt
------------------------------------
[login] Running test: login
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python27\Lib\threading.py", line 808, in __bootstrap_inner
    self.run()
  File "C:\Python27\Lib\threading.py", line 761, in run
    self.__target(*self.__args, **self.__kwargs)
  File "C:\Users\Test\projects\net10-test\net10-test\lib\site-        packages\huxley\threadpool.py", line 32, in thread
    func(*args, **kwargs)
  File "C:\Users\Test\projects\net10-test\net10-test\lib\site-packages\huxley\cmdline.py", line 69, in run_test
    screensize=screensize
  File "C:\Users\Test\projects\net10-test\net10-test\lib\site-packages\huxley\main.py", line 83, in main
    d = webdriver.Remote(remote, CAPABILITIES[browser])
  File "C:\Users\Test\projects\net10-test\net10-test\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 72, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\Test\projects\net10-test\net10-test\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 115, in start_session
    'desiredCapabilities': desired_capabilities,
  File "C:\Users\Test\projects\net10-test\net10-test\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 166, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Test\projects\net10-test\net10-test\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 164, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: None ; Stacktrace:

I have installed Huxley into a python virtualenv and ensured that the selenium server is running before attempting to start the record. My huxley file is a very basic:

[login]
url=http://2.2.2.2/login.html

I've confirmed my web application is accessible from Firefox (using the above URL) and I can navigate to 127.0.0.1:4444/wd/hub successfully.

Checking the response in Fiddler shows POST request contains a NULL value for the sessionID. The resulting NullPointerException error appears to be the root cause of my Unknown Error.

{"sessionId":null,"status":13,"value":    {"message":null,"localizedMessage":null,"suppressed":    [],"cause":null,"class":"java.lang.NullPointerException","hCode":3963113,"stackTrace":    [null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,    null,null,null,null,null,null]},"state":"unhandled     error","class":"org.openqa.selenium.remote.Response","hCode":2501105}

Any help would be much appreciated.

Cheers.

Hyphen is recorded as \u00ad

When I type a hyphen in an input field, it is being recorded into the record.json file as a soft-hyphen (\u00ad). When the record.json file is played back, the soft-hyphen is ignored by the browser, so abc-123 is replayed as abc123.

Suggestions on what I can do to fix this would be greatly appreciated. At present I'm editing the record.json file and changing \u00ad back to -. Thank you for this awesome tool!

Support for recording clicks element wise

Hi!

We were tinkering with Huxley and wanted to know if huxley supports/would support recording clicks on a webpage during a test on an element basis instead of cursor position.

This might be helpful to avoid rerecording the test when the position of a UI element on a webpage changes. We would need to rerecord the test because the old click position might not be over the UI element in the new layout. If the recording was done on element basis, the clicking would always work irrespective of the position of the element. Right now, huxley --playback-only fails because it cannot find a ui element at that position with the following error,

"raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: u"document.elementFromPoint(0, 700) is null\nBuild info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'\nSystem info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.2', java.version: '1.6.0_37'\nDriver info: driver.version: unknown" ; Screenshot: available via screen ;"

This would be helpful to avoid large amount test rerecording in a large test suite when there are small UI changes.

Please let us know your views.

Thanks,

Launching two firefox browsers in the record mode

Hi, I've installed Huxley using zip file on windows 7 64-bit. I've two selenium-webdriver versions (2.0.32 and 2.0.33) installed on my system. When I launched Huxley in record mode, it is launching two firefox browsers and from the second browser it is taking the screen shots. When I quit from Huxley, script ends with an error saying that event function not able to record the events. In the resultant created file, "record.json" is empty.I'm using 'selenium-server-standalone-2.33.0.jar'.

Please assist in resolving this problem.

Next release: fully automated option

Would it be possible for Huxley to automatically run through each webpage, without any action from the user (including rerecord) when specified?

In the Huxleyfile, an option like autorecord=true could be added for each test, which would mean on pages where no GUI changes majorly, testing is much faster.

phantomJS -not able to find elements

I tried all the things, gone through so many group discussions. Somewhere mentioned don't use find(by.linkText), I removed all , I am searching the elemet either by ID or by xpath but not working.

Error log is:
[ERROR - 2014-09-10T14:35:31.758Z] WebElementLocator - handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1410359731708
FAILED: test
org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with xpath './/
[@id='tab-rtmedia-bbpress']'","request":{"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"59","Content-Type":"application/json; charset=utf-8","Host":"localhost:25638"},"httpVersion":"1.1","method":"POST","post":"{"using":"xpath","value":".//[@id='tab-rtmedia-bbpress']"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/991e39d0-38f7-11e4-bc18-493d4e2f927e/element"}}
Command duration or timeout: 41.27 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'rtcamp-pc', ip: '192.168.0.59', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=1.9.7, platform=XP, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, acceptSslCerts=false, driverVersion=1.1.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 991e39d0-38f7-11e4-bc18-493d4e2f927e
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:404)
at org.openqa.selenium.By$ByXPath.findElement(By.java:357)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at testscripts.bbPressSettingsTest.bbPressSettings(bbPressSettingsTest.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'rtcamp-pc', ip: '192.168.0.59', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_05'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:125)
... 30 more
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: {"errorMessage":"Unable to find element with xpath './/
[@id='tab-rtmedia-bbpress']'","request":{"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"59","Content-Type":"application/json; charset=utf-8","Host":"localhost:25638"},"httpVersion":"1.1","method":"POST","post":"{"using":"xpath","value":".//_[@id='tab-rtmedia-bbpress']"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/991e39d0-38f7-11e4-bc18-493d4e2f927e/element"}}
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'rtcamp-pc', ip: '192.168.0.59', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_05'
Driver info: driver.version: unknown

Default test
Tests run: 1, Failures: 1, Skips: 0

Default suite

Total tests run: 1, Failures: 1, Skips: 0

[TestNG] Time taken by org.testng.reporters.EmailableReporter2@7a46a697: 35 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@61064425: 93 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@1c6b6478: 26 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@3abfe836: 9 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@6ed3ef1: 33 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 5 ms

Modifier keys (Shift, Alt, Control) don't record correctly

Typing characters that require modifiers keys (i.e. an @ symbol in an email address) don't properly record.

It appears the issue is a combination of the recording and playback code. The recording code only stores the keyCode, but the keyCode references the physical key pressed, not the character that results. This would be okay if the modifier key status was also recorded, but it's not.

I was going to submit a PR with a patch, but quickly realized this is a much trickier problem than it looks. I see two strategies:

  1. Record the physical key information (keyCode + modifier keys, or something similar) and try to replay that
  2. Record characters inserted and insert them in playback

With (1), the result should be more accurate. But the implementation is a bit tricker - simulating keyboard events is rife with browser differences and outstanding bugs.

On the other hand (2) is less accurate (not actually replaying key events, so in-app key bindings won't fire), but easier to implement (setting the value of inputs is much easier than replaying key events).

I'm thinking of working up a PR to try solving this, but want to get feedback on which approach makes more sense first.

Where do you call `huxley` from?

I have huxley installed, but I always get a command not found.

Proof it's installed:

$ sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install huxley
Requirement already satisfied (use --upgrade to upgrade): huxley in /Users/lucy/Library/Python/2.7/lib/python/site-packages
Requirement already satisfied (use --upgrade to upgrade): selenium==2.35.0 in /Users/lucy/Library/Python/2.7/lib/python/site-packages (from huxley)
Requirement already satisfied (use --upgrade to upgrade): plac==0.9.1 in /Users/lucy/Library/Python/2.7/lib/python/site-packages (from huxley)
Requirement already satisfied (use --upgrade to upgrade): Pillow==2.2.1 in /Library/Python/2.7/site-packages (from huxley)
Requirement already satisfied (use --upgrade to upgrade): jsonpickle==0.4.0 in /Library/Python/2.7/site-packages (from huxley)
Cleaning up...

Install command from #53

And here's the error:

examples (master) $ huxley --record
-bash: huxley: command not found

I'm running the huxley --record command from the examples folder, is that right? Am I missing something?

Thanks!

How Could I use huxley with proxy?

I want to use huxley to test my website, but my company have set the firewall, so I must set a proxy to open my website by urlopen.
How can I do?

Huxley Install on Window 8

I'm I have installed Huxley on a Window 8 machine, however when I try to execute the Huxley record command I get the following error...

No huxleyfile found anywhere..

any idea what is wrong?

Cannot install: "Could not find any downloads that satisfy the requirement PIL==1.1.7 (from huxley)"

On installation, I receive this when the Huxley installation reaches PIL.

Could not find any downloads that satisfy the requirement PIL==1.1.7 (from huxley)
Some externally hosted files were ignored (use --allow-external PIL to allow).
Cleaning up...
No distributions at all found for PIL==1.1.7 (from huxley)
Storing debug log for failure in /Users/nathan/Library/Logs/pip.log

Have installed Pillow separately, still receiving issue.

screenshot 2014-01-23 09 32 59

Support for Scrolling Documents

I think this tool is awesome, just want to make sure I understand the constraints.

I set up a record that tried to scroll down a page, click an element, and record the ui reaction.

The screenshot is taken full-document-length, which seems good. But the click records x, y relative to the viewport, and no scroll action is ever recorded. The result is that unintended places are clicked during the playback.

Is this a bug, intended feature, or known limitation?

Stopping Huxley creates this stacktrace - potential problem?

see below

Traceback (most recent call last):
  File "/Users/luca/anaconda/bin/huxley", line 9, in <module>
    load_entry_point('Huxley==0.4', 'console_scripts', 'huxley')()
  File "/Users/luca/anaconda/lib/python2.7/site-packages/huxley/cmdline.py", line 153, in main
    sys.exit(plac.call(_main))
  File "/Users/luca/anaconda/lib/python2.7/site-packages/plac_core.py", line 309, in call
    cmd, result = parser_from(obj).consume(arglist)
  File "/Users/luca/anaconda/lib/python2.7/site-packages/plac_core.py", line 195, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/Users/luca/anaconda/lib/python2.7/site-packages/huxley/cmdline.py", line 130, in _main
    screensize=screensize
  File "/Users/luca/anaconda/lib/python2.7/site-packages/huxley/main.py", line 136, in main
    return 0
  File "/Users/luca/anaconda/lib/python2.7/contextlib.py", line 154, in __exit__
    self.thing.close()
  File "/Users/luca/anaconda/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 445, in close
    self.execute(Command.CLOSE)
  File "/Users/luca/anaconda/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
    self.error_handler.check_response(response)
  File "/Users/luca/anaconda/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: u"Window not found. The browser window may have been closed.\nCommand duration or timeout: 12 milliseconds\nBuild info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'\nSystem info: host: 'lucas-air', ip: '192.168.2.165', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.6.0_65'\nSession ID: 6a479e5d-d23a-9a49-86ed-eb58defb4264\nDriver info: org.openqa.selenium.firefox.FirefoxDriver\nCapabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=24.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]" ; Screenshot: available via screen ; Stacktrace: 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable (ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed (ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:569)
    at org.openqa.selenium.remote.RemoteWebDriver.close (RemoteWebDriver.java:418)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke (Method.java:597)
    at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke (EventFiringWebDriver.java:101)
    at com.sun.proxy.$Proxy2.close (None:-1)
    at org.openqa.selenium.support.events.EventFiringWebDriver.close (EventFiringWebDriver.java:194)
    at org.openqa.selenium.remote.server.handler.CloseWindow.call (CloseWindow.java:32)
    at org.openqa.selenium.remote.server.handler.CloseWindow.call (CloseWindow.java:1)
    at java.util.concurrent.FutureTask$Sync.innerRun (FutureTask.java:303)
    at java.util.concurrent.FutureTask.run (FutureTask.java:138)
    at org.openqa.selenium.remote.server.DefaultSession$1.run (DefaultSession.java:170)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask (ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:918)
    at java.lang.Thread.run (Thread.java:695) 

Screenshot dimensions not matching those specified in Huxleyfile

Hey there,

I’m noticing that seems a bit weird is that the actual dimensions of snapped screenshots that I’m seeing don’t seem to match the dimensions that I specify in my Huxleyfile.

For example;

screensize=1024x768 will reliably result in an image of 1009x663 being written to disk, as will screensize=320x768 result in 305x663.

Seems fair to assume that the browser chrome is being deducted from the viewport area given the consistent 15px & 105px reduction in image size.

I’m assuming that this is a bug? Kinda seems weird behaviour, also is inconsistent to what other tools (phantomjs, for example) do—which is return an image of the same size as specified by screensize.

PS: Really loving Huxley, thanks for open-sourcing it! 💃

when finish record, wrtie record.json file error

when q+enter to finish record, after huxley playback, wrtie record.json file error
I use windows7, default encode is gbk, when I finished record, huxley report decodeError.
the trackback is:
Traceback (most recent call last):
File "E:\Python27\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "E:\Python27\lib\threading.py", line 763, in run
self.__target(_self.__args, *_self.__kwargs)
File "build\bdist.win-amd64\egg\huxley\threadpool.py", line 32, in thread
func(_args, *_kwargs)
File "build\bdist.win-amd64\egg\huxley\cmdline.py", line 69, in run_test
screensize=screensize
File "build\bdist.win-amd64\egg\huxley\main.py", line 110, in main
TestRun.record(local_d, d, (url, postdata), screensize, filename, diffcolor,
sleepfactor, save_diff)
File "build\bdist.win-amd64\egg\huxley\run.py", line 152, in record
cls.rerecord(test, path, url, remote_d, sleepfactor, diffcolor, save_diff)
File "build\bdist.win-amd64\egg\huxley\run.py", line 75, in rerecord
run._playback(sleepfactor)
File "build\bdist.win-amd64\egg\huxley\run.py", line 95, in _playback
step.execute(self)
File "build\bdist.win-amd64\egg\huxley\steps.py", line 61, in execute
print ' Typing', self.key
UnicodeEncodeError: 'gbk' codec can't encode character u'\xbe' in position 0: il
legal multibyte sequence

Javascript error when executing "return Date.now();" when using Internet Explorer

My Huxley version is 0.4. Selenium Standalone Server is 2.35.0. IEDriverServer is 2.35.1. OS is Windows Server 2008 R2. Browser is IE 8.
I found that this code

start_time = d.execute_script('return Date.now();')

produces javascript error when using IE while Firefox is ok.

Why not using Python time to get start time?

Below is my traceback. Thank you.


C:\Program Files\Python27\Scripts\huxley.exe --record


Running Huxley file: Huxleyfile


Running test: toggle
Begin record
Traceback (most recent call last):
File "C:\Program Files\Python27\Scripts\huxley-script.py", line 9, in

load_entry_point('Huxley==0.4', 'console_scripts', 'huxley')()
File "build\bdist.win-amd64\egg\huxley\cmdline.py", line 153, in main
File "C:\Program Files\Python27\lib\site-packages\plac_core.py", line 309, in
call
cmd, result = parser_from(obj).consume(arglist)
File "C:\Program Files\Python27\lib\site-packages\plac_core.py", line 195, in
consume
return cmd, self.func(_(args + varargs + extraopts), *_kwargs)
File "build\bdist.win-amd64\egg\huxley\cmdline.py", line 130, in _main
File "build\bdist.win-amd64\egg\huxley\main.py", line 109, in main
File "build\bdist.win-amd64\egg\huxley\run.py", line 109, in record
File "C:\Program Files\Python27\lib\site-packages\selenium-2.32.0-py2.7.egg\se
lenium\webdriver\remote\webdriver.py", line 397, in execute_script
{'script': script, 'args':converted_args})['value']
File "C:\Program Files\Python27\lib\site-packages\selenium-2.32.0-py2.7.egg\se
lenium\webdriver\remote\webdriver.py", line 165, in execute
self.error_handler.check_response(response)
File "C:\Program Files\Python27\lib\site-packages\selenium-2.32.0-py2.7.egg\se
lenium\webdriver\remote\errorhandler.py", line 152, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: u"JavaScript error (WARN
ING: The server did not provide any stacktrace information)\nCommand duration or
timeout: 168 milliseconds\nBuild info: version: '2.35.0', revision: 'c916b9d',
time: '2013-08-12 15:42:01'\nSystem info: os.name: 'Windows Server 2008 R2', os.
arch: 'x86', os.version: '6.1', java.version: '1.7.0_25'\nSession ID: c8b4e699-d
daf-4f20-8996-34b4dd619916\nDriver info: org.openqa.selenium.ie.InternetExplorer
Driver\nCapabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBe
havior=0, ignoreZoomSetting=false, enablePersistentHover=true, ie.ensureCleanSes
sion=false, browserName=internet explorer, enableElementCacheCleanup=true, unexp
ectedAlertBehaviour=dismiss, version=8, ie.usePerProcessProxy=false, ignoreProte
ctedModeSettings=false, cssSelectorsEnabled=true, requireWindowFocus=false, init
ialBrowserUrl=http://localhost:3598/, handlesAlerts=true, ie.forceCreateProcessA
pi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitch
es=, takesScreenshot=true}]" ; Screenshot: available via screen ; Stacktrace: Me
thod newInstance0 threw an error in None

pip install huxley failed on Mac OSX

Always showing error:

_imagingft.c:62:10: fatal error: 'freetype/fterrors.h' file not found

#include <freetype/fterrors.h>

         ^

1 warning and 1 error generated.

error: command 'clang' failed with exit status 1

Using other browsers question

Hello,

this is awesome tool - thanks for making this available !
I have a question about how to define other browsers, default is firefox
as I can see. I couldn't find any env variable that would control this,
so I made some changes to main.py and cmdline.py to support this
via env variables. But in case I re-invented the wheel, please tell me how
to it properly :)

Thanks !
Alex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.