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

Add "id" as a property I can set on Typeahead for use in automated testing #138

Closed
rsshilli opened this issue Feb 13, 2017 · 7 comments
Closed
Milestone

Comments

@rsshilli
Copy link

Hello!

I'm using this package and it's working beautifully. Thank you for your hard work!

Now I'm trying to create a few automated tests. I have 4 Typeahead components on the my page. I'd love to identify them like:

<Typeahead id="assignedToTypeahead" options=....>

So that I can use that ID in WebdriverIO/Selenium to type into the Typeahead and enter data. I'm surprised I'm the first person to hit this issue, honestly. I've tried putting the id attribute there, but there's nothing in my webpage when I look at it with Chrome's developer tools.

How do others write automated end to end tests?

Ryan

@ericgio
Copy link
Owner

ericgio commented Feb 13, 2017

Seems reasonable. I assume the id would just go on the outermost div?

@rsshilli
Copy link
Author

I could make that work, but ideally it would be on the first input that you type into.

@ericgio
Copy link
Owner

ericgio commented Feb 18, 2017

While it solves your particular problem, I'm not sure applying id to a sub-component is very intuitive. I think the right solution is for the input to be more customizable, just as the menu is. That's not trivial, though.

@rsshilli
Copy link
Author

Agreed. And I don't think this is worth overthinking. For my case, and I suspect most people's, I just want to call something like:

"#myTypeaheadId".setText("This is some text");

If you set it on the outside div, that'll work fine too. I can then use a selector to get to the first input.

@ericgio
Copy link
Owner

ericgio commented Mar 2, 2017

Are you able to use CSS class selectors? That seems like the easiest solution to your problem.

@rsshilli
Copy link
Author

rsshilli commented Mar 20, 2017

Yes, I already have a work around to this issue with CSS selectors. I can set my own ID on the outermost element and work from there (hoping you don't change the underlying structure excessively).

Maybe the right solution would be to take the ID of the outermost element, if it's set, and then set IDs on the elements that you create inside by appending various strings? So if the outermost element has ID "projectManager" then you could put IDs like "projectManager_textInput" and "projectManager_dropDown" or whatever. Then people could get at whatever they wanted.

@ericgio ericgio added this to the 2.0 milestone Jul 20, 2017
@ericgio
Copy link
Owner

ericgio commented Jul 21, 2017

inputProps prop added in v2.0.0-alpha.1 that allows adding arbitrary props to the input.

@ericgio ericgio closed this as completed Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants