GithubHelp home page GithubHelp logo

chai-webdriverio's People

Contributors

aaronmcadam avatar annikanissen avatar christian-bromann avatar greenkeeper[bot] avatar joshlam avatar klamping avatar marcodejongh avatar mltsy avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

chai-webdriverio's Issues

Publish on npm?

Awesome work! Just curious if you plan to publish this on NPM. I'd use it! (But I don't want to tie my project to a package from a personal repo that's not published on npm)

support for scoping selectors

New to both webdriverio and chai-webdriverio.

I am using something like

var linkToArticleSelector = "a[href='link-to-article']"
expect(linkToArticleSelector).to.be.there();

While this works as expected, is there a way to deal with nested/scoped selectors?

Let's say the link was in the header on the page. I'd like to assert that the link was indeed within the header.

e.g

expect(header).to.have.selector(linkToArticleSelector)

Readme missing `.dom` in a few places

I'd be happy to submit a PR for this if you can confirm that I'm right about this being an issue. It looks like the Readme has several examples that are missing the .dom flag, which I believe is required... is that right?

False Positives

We recently discovered that we were getting some false positives with the chai-webdriverio assertions. If we didn't include the parenthesis, our tests would continue without failing. Ouside the scope of chai-webdriverio?

.to.be.visible

instead of

.to.be.visible()

Also, the README shows 2 different ways to use not. Which is correct?

.to.not.be.visible()
.not.to.have.text('property')

Suggestions

Thanks for kicking off the initial work for this chai plugin, here are some suggestions after reviewing the code:

  • create a fresh repository instead of copying the chai-webdriver one
  • do not use coffee script (makes it more difficult for other people to contribute)
  • make sure it works in sync as well as in async mode
  • question: is that dom flag necessary?

Cheers

support for have.selector

I am making a switch from using Capybara/Rspec in to WebdriverIO so please let me know if the following is not an issue or doesn't belong to chai-webdriverio

rspec expect style assertions are great and capybara patched in a few custom matchers/assertions as syntactic sugar to improve readability. So, it supported something like

expect(page).to have_selector(.css-selector)

Is it possible to do something like this is chai when using webdriverio?

e.g.

expect(browser).to.have.selector(.css-selector)

what I gather from the docs is that the first part should actually be a selector. Is it possible to assert a selector on the whole page? If not, can this be supported?

An in-range update of mocha is breaking the build 🚨

Version 3.4.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.4.0

Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.

This week's highlights:

  • allowUncaught added to commandline as --allow-uncaught (and bugfixed)
  • warning-related Node flags

🎉 Enhancements

🐛 Fixes

🔩 Other

Commits

The new version differs by 9 commits0.

  • 7554b31 Add Changelog for v3.4.0
  • 9f7f7ed Add --trace-warnings flag
  • 92561c8 Add --no-warnings flag
  • ceee976 lint test/integration/fixtures/simple-reporter.js
  • dcfc094 Revert "use semistandard directly"
  • 93392dd no special case for macOS running Karma locally
  • 4d1d91d --allow-uncaught cli option
  • fb1e083 fix allowUncaught in browser
  • 4ed3fc5 Add license report and scan status

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Change regex assertion to `.match` and add `contain` flag?

It might be nice to give the regex assertion its own name instead of relying on argument type to choose how to match. This would be consistent with chai-webdriver and also make an include or contain flag for the text assertion a little less confusing (contain would also be consistent with chai-webdriver)

Replace the `immediately` flag?

I'm not sure the "immediately" flag actually does anything... ?? @christian-bromann has told me (if I understood correctly) that all webdriverio methods that look for elements (isVisible, getText, etc) will implicitly waitForExist until the default timeout expires. So there's no way to implement a functional immediately flag, as I understand it.

We could however implement an eventually flag that would add some timeout, or maybe even take a timeout as a parameter, and wait for the specified amount of time. (which would follow a recommended practice of setting your default timeout to 0, and waiting as necessary).

Or we could just remove it altogether, and if you need to wait, you can do it explicitly before firing a test :)

Use already selected elements instead of string

Is it possible to pass a selected element to expect, rather than a string selector?

Is there any way I could use it like this?

const element = $('.css-selector')
expect(element).to.be.there()

Thanks

Dev and peer dependencies are not right

The Peer Dependency on chai is way too strict (~4.0.1)

In trying to fix this, I ran into unmet peer dependencies in the devDependencies graph, stemming from eslint-config-airbnb. I replaced it with eslint-config-airbnb-base since this project doesn't depend on react, and added the remaining peer (eslint-plugin-import), but was unable to get eslint to work (./node_modules/.bin/eslint src/assertions/text.js now complains that it Cannot find module babel-eslint) I'm curious whether we need eslint at all? I have never used it before, so I many just be doing something wrong, and wanted to ask what it is there for, and how I should be testing to make sure it works! :)

Could it just be something a developer can install and run globally? If we don't need it as part of the project, I'll remove it. If we do, I'll try to fix it by adding all the necessary dependencies. I just wanted to find out how/why it got to the current state before I made any more changes...

Read me misleading?

Ran the code from the readme:

// Start with a webdriver instance:
var sw = require('selenium-webdriver');
var driver = new sw.Builder()
  .withCapabilities(sw.Capabilities.chrome())
  .build()

// And then...
var chai = require('chai');
var chaiWebdriver = require('chai-webdriver');
chai.use(chaiWebdriver(driver));

// And you're good to go!
driver.get('http://github.com');
chai.expect('#site-container h1.heading').dom.to.not.contain.text("I'm a kitty!");

Got this:

TypeError: checkSizzleExists(...).then(...).then(...).thenCatch is not a function
    at finder (C:\Users\User\AppData\Roaming\npm\node_modules\chai-webdriver\node_modules\webdriver-sizzle\lib\webdriver_sizzle.js:60:10)
    at call (C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\webdriver.js:1066:28)
    at C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\webdriver.js:907:19
    at ManagedPromise.invokeCallback_ (C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\promise.js:1384:14)
    at TaskQueue.execute_ (C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\promise.js:3092:14)
    at TaskQueue.executeNext_ (C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\promise.js:3075:27)
    at asyncRun (C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\promise.js:2982:25)
    at C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\promise.js:676:7
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.call(function)
    at thenableWebDriverProxy.call (C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\webdriver.js:901:23)
    at thenableWebDriverProxy.findElementsInternal_ (C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\webdriver.js:1066:17)
    at thenableWebDriverProxy.findElements (C:\Users\User\AppData\Roaming\npm\node_modules\selenium-webdriver\lib\webdriver.js:1043:19)
    at Function.one.all (C:\Users\User\AppData\Roaming\npm\node_modules\chai-webdriver\node_modules\webdriver-sizzle\lib\webdriver_sizzle.js:64:19)
    at assertElementExists (C:\Users\User\AppData\Roaming\npm\node_modules\chai-webdriver\lib\index.js:18:16)
    at Proxy.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\chai-webdriver\lib\index.js:90:14)
    at Proxy.methodWrapper (C:\Users\User\AppData\Roaming\npm\node_modules\chai\lib\chai\utils\addMethod.js:57:25)
    at Object.<anonymous> (C:\Users\User\src\izel\tests\chai.js.old:17:62)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)

C:\Users\User\src\izel (master)

Make chai-webdriverio compatible with WebdriverIO v5

The new version 5 of WebdriverIO contains a lot of breaking changes, so that this chai plugin no longer is compatible. It would be really awesome, if this plugin would be updated to work with WebdriverIO v5.

The changelog for WebdriverIO v5 can be found here.

Help Wanted! (i.e. new maintainers)

Having trouble with this gem, and need to make some fixes? Wish you had a cool open-source project to brag about? Now you can! chai-webdriverio needs a new maintainer (maybe someone who is using webdriverio in their daily work...) - and it could be you!

(I'm no longer using webdriverio for anything, so I can't afford enough time/energy to maintain this gem, but I'm sure @marcodejongh would be happy to accept help from a new maintainer)

Add "class" assertion

Add an assertion for checking that element class equals/matches a value:

expect('.element').to.have.class(String|Regex)

Currently, can be achieved via attribute assertion (implemented in #53)

Add an "exist" assertion

I could also try to find time for a PR for this, if you're available to review and merge it (just wanted to check on that before working on it)

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Add a 'dom' or 'elements' method to qualify assertions?

chai-webdriver uses a .dom flag to start the assertion chain, like this:

expect(...).dom.to.be.there

This library was originally designed without that, because it's a somewhat awkward token, syntactically. However, there are 2 good reasons for having some such unique flag to start the chain:

  1. It namespaces the assertions. If we had such a flag, we could use any name for our assertions (including exist, which we had to avoid, and call there)
  2. When chai-webdriverio is not defined, it would cause the test to fail even if the assertion is called without parenthesis. Without it, you can call .visible outside the scope of chai-webdriverio and have no failure, because .visible just returns undefined, like this: #37

Possible names for this flag:

  • .dom (to match 'chai-webdriverio`)
  • .wdio
  • .elements
  • .element (potentially, we could offer both elements and element, and use the respective webdriverio method)
  • .html ... ? This isn't quite right - I'm basically out of ideas that actually make sense 😉

Additional matchers

Just wanted to start an issue with a few additional matchers that I've wished were available here for when I get a chance to implement some (mostly copies from chai-webdriver):

  • .have.htmlClass(name)
  • .have.attribute(name, value)
  • .have.element(selector) or contain(selector) (?)
  • .be.disabled()

chai-webdriverio throws an exception anytime an expect clause with displayed is fired

I am trying to port over to using the new chai-webdriverio. I am getting exceptions with the assertion functions in this package. I have created a demo here:

https://github.com/rpii/wdio-test

it blows up on simple test case. from the readme in the readme.md for the above project:

I am using the newly updated chai-webdriverio assertions library v 1.0.0.

the code at line of basic.test.spec.js: ... expect(title, 'WebdriverIO · Next-gen WebDriver test framework for Node.js').to.be.displayed();

causes an error to be thrown deep into the hook callbacks.

This is the stack you see, but there is another exception stack that gets covered up

Error: selector needs to be typeof string or function at Object. (C:\Users\rpeter\Development\automated-test\wdio-test\node_modules@wdio\runner\node_modules\webdriverio\build\utils.js:39:32) at Module._compile (internal/modules/cjs/loader.js:738:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10) at Module.load (internal/modules/cjs/loader.js:630:32) at tryModuleLoad (internal/modules/cjs/loader.js:570:12) at Function.Module._load (internal/modules/cjs/loader.js:562:3) at Module.require (internal/modules/cjs/loader.js:667:17) at require (internal/modules/cjs/helpers.js:20:18) at Object. (C:\Users\rpeter\Development\automated-test\wdio-test\node_modules@wdio\runner\node_modules\webdriverio\build\multiremote.js:16:14) at Browser.runCommand (C:\Users\rpeter\Development\automated-test\wdio-test\node_modules@wdio\sync\build\wrapCommand.js:31:24) at Browser. (C:\Users\rpeter\Development\automated-test\wdio-test\node_modules@wdio\sync\build\wrapCommand.js:53:31) at isOneElementDisplayed (C:\Users\rpeter\Development\automated-test\wdio-test\node_modules\chai-webdriverio\dist\assertions\displayed.js:15:27) at Browser. (C:\Users\rpeter\Development\automated-test\wdio-test\node_modules\chai-webdriverio\dist\assertions\displayed.js:36:24) at C:\Users\rpeter\Development\automated-test\wdio-test\node_modules@wdio\sync\build\runFnInFiberContext.js:20:25

it starts from client$$(selector) in the code below:

var isOneElementDisplayed = function isOneElementDisplayed(client, selector) {
var elements = client.$$(selector);
var filteredList = elements.filter(function (element) {
return element.isDisplayed();
});

return filteredList.length > 0;

};

...

Anyone have any ideas?

Transpile script fails on npm install

I've tried to use this directly from GitHub by adding the following to my package.json:
"chai-webdriverio": "git://github.com/marcodejongh/chai-webdriverio.git#master"

Am I missing something?

When running npm install, I get the following output:

❯ npm install

> [email protected] postinstall /path/to/project/node_modules/chai-webdriverio
> npm run transpile

> [email protected] transpile /path/to/project/node_modules/chai-webdriverio
> babel src -d build

src doesn't exist

npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/aaron/.nvm/versions/node/v6.2.0/bin/node" "/Users/aaron/.nvm/versions/node/v6.2.0/bin/npm" "run" "transpile"
npm ERR! node v6.2.0
npm ERR! npm  v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] transpile: `babel src -d build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] transpile script 'babel src -d build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the chai-webdriverio package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     babel src -d build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs chai-webdriverio
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls chai-webdriverio
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR!     /path/to/project/node_modules/chai-webdriverio/npm-debug.log
npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/aaron/.nvm/versions/node/v6.2.0/bin/node" "/Users/aaron/.nvm/versions/node/v6.2.0/bin/npm" "install"
npm ERR! node v6.2.0
npm ERR! npm  v3.8.9
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `npm run transpile`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'npm run transpile'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the chai-webdriverio package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run transpile
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs chai-webdriverio
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls chai-webdriverio
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /path/to/project/npm-debug.log

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.