Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Commit

Permalink
remove deprecated functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
EndangeredMassa committed May 13, 2015
1 parent 205c300 commit c9516f7
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 267 deletions.
41 changes: 0 additions & 41 deletions API.md
Expand Up @@ -192,10 +192,6 @@ browser.click '.menu-button'
browser.waitForElementNotVisible('.menu', 1000)
```

### browser.waitForElement(cssSelector, timeout=3000)

Deprecated synonym for `browser.waitForElementVisible(cssSelector, timeout=3000)`

### browser.getUrl()

Returns the current url
Expand Down Expand Up @@ -968,43 +964,6 @@ about the test when the assertion fails.
browser.assert.imgLoaded '.logo'
```
### ~~browser.assert.imagesMatch(image1, image2, tolerance=0)~~

**Deprecated**

Asserts that the provided images
are equal within the given `tolerance`.

Images can be provided as
base64-encoded PNG buffers.
You can pass the value returned
by `getScreenshot` directly into this method.

It is recommended that you leave the `tolerance`
value at 0 unless you are fully aware
of what you are testing.
Allowing a tolerance larger than 0
can lead to tests that pass on bad input.

Warning: this method is experimental and slow.
It uses the [img-diff](https://github.com/groupon-testium/img-diff)
library.
You can use `@slow(4000)` in tests to
notify mocha of this.

```coffee
it 'has the same UI across implementations', ->
@slow(5000)

browser.navigateTo '/products'
screenshot1 = browser.getScreenshot()

browser.navigateTo '/products-rewrite'
screenshot2 = browser.getScreenshot()

browser.assert.imagesMatch(screenshot1, screenshot2)
```

## Capabilities
This is an object based on
Expand Down
10 changes: 0 additions & 10 deletions README.md
Expand Up @@ -71,13 +71,6 @@ system-level libraries.
- **phantomjs 1.9.7+** (only for headless testing)
- **java 7+** (only when running in browsers)

**optional**

- ~~**libpng**~~ (**deprecated**) (for image diffing)
<br>[Ubuntu] `sudo apt-get install libpng-dev`
<br>[OS X] `brew install libpng`


## Configuration

testium uses [`rc`](https://www.npmjs.org/package/rc) for configuration.
Expand Down Expand Up @@ -259,7 +252,6 @@ Method | Description
`browser.capabilities` | Is an object describing the [WebDriver capabilities](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Capabilities_JSON_Object) that the current browser supports.
`browser.getElement(cssSelector)` | Finds an element on the page using the `cssSelector` and returns an Element.
`browser.getElements(cssSelector)` | Finds all elements on the page using the `cssSelector` and returns an array of Elements.
~~`browser.waitForElement(cssSelector, timeout=3000)`~~ | **Deprecated** *(synonym for `browser.waitForElementVisible(cssSelector, timeout=3000)`*
`browser.waitForElementVisible(cssSelector, timeout=3000)` | Waits for the element at `cssSelector` to exist and be visible, then returns the Element. Times out after `timeout` ms.
`browser.waitForElementNotVisible(cssSelector, timeout=3000)` | Waits for the element at `cssSelector` to exist and not be visible, then returns the Element. Times out after `timeout` ms.
`browser.waitForElementExist(cssSelector, timeout=3000)` | Waits for the element at `cssSelector` to exist, then returns the Element. Times out after `timeout` ms. Visibility is not considered.
Expand All @@ -272,7 +264,6 @@ Method | Description
`browser.getPageSource()` | Returns the current page's html source.
`browser.getPageSize()` | Returns the current window's size.
`browser.setPageSize({height, width})` | Sets the current window's size.
~~`browser.getScreenshot(selector)`~~ | **Deprecated** Returns screenshot as a base64 encoded PNG bounded by the element at `cssSelector`.
`browser.getScreenshot()` | Returns screenshot as a base64 encoded PNG.
`browser.click(cssSelector)` | Calls Click on the Element found by the given `cssSelector`.
`browser.type(cssSelector, value)` | Sends `value` to the input Element found by the given `cssSelector`.
Expand Down Expand Up @@ -342,7 +333,6 @@ Method | Description
`browser.assert.elementDoesntExist(selector)` | Throws exceptions if selector exists.
`browser.assert.httpStatus(statusCode)` | Throws exceptions if current status code is not equal to the provided statusCode.
`browser.assert.imgLoaded(selector)` | Throws exceptions if selector doesn't match a single `<img>` element that has both loaded and been decoded successfully. Allows an optional extra _initial_ docstring argument, for semantic documentation about the test when the assertion fails.
~~`browser.assert.imagesMatch(image1, image2, tolerance=0)`~~ | **Deprecated** Throws exceptions if the images don't match within the given tolerance. Warning: this method is experimental and slow. You can use `@slow(4000)` in tests to notify mocha of this.

### Element

Expand Down
2 changes: 1 addition & 1 deletion lib/assert/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions lib/browser/element.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 3 additions & 26 deletions lib/browser/page.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 0 additions & 64 deletions lib/img_diff.js

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Expand Up @@ -57,8 +57,5 @@
"node-static": "~0.7.6",
"npub": "0.0.6",
"rimraf": "^2.2.8"
},
"optionalDependencies": {
"img-diff": "~0.1.0"
}
}
1 change: 0 additions & 1 deletion src/assert/index.coffee
Expand Up @@ -37,7 +37,6 @@ class Assertions

[
require('./element')
require('../img_diff')
require('./imgLoaded')
require('./navigation')
].forEach (mixin) ->
Expand Down
5 changes: 0 additions & 5 deletions src/browser/element.coffee
Expand Up @@ -82,11 +82,6 @@ ElementMixin =

@driver.getElements(selector)

waitForElement: (selector, timeout) ->
console.warn 'DEPRECATED: waitForElement; use waitForElementVisible instead.'
hasType 'getElements(selector) - requires (String) selector', String, selector
@_waitForElement(selector, isVisiblePredicate, isVisibleFailure, timeout)

waitForElementVisible: (selector, timeout) ->
hasType 'getElements(selector) - requires (String) selector', String, selector
@_waitForElement(selector, isVisiblePredicate, isVisibleFailure, timeout)
Expand Down
24 changes: 2 additions & 22 deletions src/browser/page.coffee
Expand Up @@ -30,7 +30,6 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###

{crop: cropScreenshot} = require '../img_diff'
{hasType} = require 'assertive'

module.exports =
Expand All @@ -40,27 +39,8 @@ module.exports =
getPageSource: ->
@driver.getPageSource()

_cropScreenshotBySelector: (screenshot, selector) ->
element = @driver.getElement(selector)
position = element.getLocationInView()
size = element.getSize()

elementData =
x: position.x
y: position.y
width: size.width
height: size.height

cropScreenshot(screenshot, elementData)

getScreenshot: (selector) ->
if selector?
hasType 'getScreenshot(selector) - requires (String) selector or nothing', String, selector
console.warn 'DEPRECATED: getScreenshot(selector); use getScreenshot() instead.'
screenshot = @driver.getScreenshot()
@_cropScreenshotBySelector(screenshot, selector)
else
@driver.getScreenshot()
getScreenshot: ->
@driver.getScreenshot()

setPageSize: (size) ->
invocation = 'setPageSize(size={height, width})'
Expand Down
62 changes: 0 additions & 62 deletions src/img_diff.coffee

This file was deleted.

27 changes: 0 additions & 27 deletions test/integration/screenshot.test.coffee
Expand Up @@ -16,30 +16,3 @@ describe 'screenshots', ->
it 'captures the page', ->
assert.truthy @indexScreenshot.length > 0

it 'can be scoped to a selector', ->
formScreenshot = @browser.getScreenshot('#the-form')
assert.truthy 'selector screenshot is smaller than the page', formScreenshot.length < @indexScreenshot.length

describe 'comparing', ->
before ->
@indexScreenshot ?= getIndexScreenshot(@browser)

it 'to itself succeeds', ->
@browser.assert.imagesMatch(@indexScreenshot, @indexScreenshot)

it 'to something else fails', ->
@browser.navigateTo '/other-page.html'
@browser.assert.httpStatus 200
otherScreenshot = @browser.getScreenshot()

error = assert.throws =>
@browser.assert.imagesMatch(@indexScreenshot, otherScreenshot)
expectedError = /^Images are .+ different! Tolerance was 0\.$/
assert.match expectedError, error.message

it 'allows tolerance', ->
@browser.navigateTo '/index-diff.html'
@browser.assert.httpStatus 200
diffScreenshot = @browser.getScreenshot()
@browser.assert.imagesMatch(@indexScreenshot, diffScreenshot, 60.00)

0 comments on commit c9516f7

Please sign in to comment.