Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow selenium WebElement to be passed to expect in place of a selector #2

Open
b3nj4m opened this issue Jun 27, 2014 · 6 comments
Open
Assignees

Comments

@b3nj4m
Copy link
Owner

b3nj4m commented Jun 27, 2014

No description provided.

@b3nj4m b3nj4m self-assigned this Jun 27, 2014
@benmosher
Copy link

FYI: I more or less did this in my fork. I didn't spend a ton of time verifying, and I also made it a hard requirement: no more selector strings. I think this is a little true-r to Chai/BDD testing than the original chai-webdriver code.

I'm happy to post a PR if you want, just noticed you bumped the version to 4.0. I mostly wanted to be able to use multiple WebDriver instances; passing the driver with the plugin initialization hampers this.

@b3nj4m
Copy link
Owner Author

b3nj4m commented Dec 17, 2014

What's the use-case for multiple driver instances?

@benmosher
Copy link

Iterating a test set over a different browser drivers, potentially.

I'll admit, my initial impetus for the changes in the fork stemmed from some misunderstanding of the driver lifetime; I thought it was being created/destroyed per test case. Given the spec suite for this project, that's clearly not necessary.

That said, I still like having the expect take a selection instead of a selector.

@benmosher
Copy link

As a (contrived) example: Selenium's parallel_flows.js example would not be feasible without removing the driver from the Chai helper.

@b3nj4m
Copy link
Owner Author

b3nj4m commented Dec 17, 2014

Hmm. If the driver were not supplied, selectors, and the visible function would not be usable. I don't like the inconsistency that creates in the API...

With this issue, I was thinking of allowing an element to be passed in place of a selector, but not making driver optional. Is that still useful to you?

@benmosher
Copy link

I think it is useful, but I'm using 100% Sizzle selectors and thus would need to send a meaningless driver to set up the helper with Chai. If you check out the readme on the fork, it's just expect($(selector)) in lieu of expect(selector). A worthwhile extra 3 characters to simplify the functionality, IMO. Plus, you can reuse an existing selection in multiple assertions.

I agree it's inconsistent with the existing API, for sure, but I think it might be a reasonable major-release-worthy breaking change if you liked it as an overall direction. If not, I'm pleased with my fork so far--and really appreciate your additions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants