JQuery Select2 - how to configure the ID to be predictable - testing

I’ve searched here and in the Select2 forum and I’ve found just one answer regarding the issues related to test automation and the dynamic nature of ID that are generated by Select2.
AFAIK at my company, we are using Select2 integrated with Bootstrap 3.7 and for some Select2 use cases we have got same findings done here -> https://medium.com/#kcmueller.
I’m preparing a webinar regarding test automation using TestCafe & TestCafe Studio and when trying to use this -> Select2 Github ChangeLog Page as a playground, I’ve seen that on select with option groups, id are created in what seems a random/dynamic way, making impossible any kind of automation that does not depends on finding/clicking things by position.
In addition, I’m not able to find documentation that explains how the ID of the main select2 element is generated. In the Select2 example page id is s2id_e1 for a plain select with id e1.
I’m very confused, because I’m not able to find any documentation that will allow me to understand what is the algorithm used, if algorithm changes according the select characteristics: single selection, multiple selection, option groups.
Hope my explanation is clear.
Any hint?
Any documentation?
Any option other to develop some kind of adapter, as I’ve read in the only post I’ve found regarding test automation?
Thanks a lot

I don't know if it's possible to make Select2 to generate consistent IDs, but it's not a problem if you are using TestCafe. TestCafe provides a lot of ways to locate an item despite its ID and position. For example, the item highlighted in the screenshot can be accessed via Selector('.select2-choice > span').withExactText('Alaska'). The full description of TestCafe selectors can be found here.

Related

Do Karate UI support Angular UI based application testing

If karate supports Angular testing, can i have some example so that i can look into it.
Have been going through locators given at https://intuit.github.io/karate/karate-core/#locators but unable to get exact information on how to proceed.
There is no need, Karate works with plain HTML.
And if you need to do some specifc JS helpers (which is all that frameworks that claim to support Angular do), just use the tips here and make re-usable functions: https://stackoverflow.com/a/60800181/143475
If you still have a question, ask a new question and provide a sample (can be online, see examples in link above) for us to understand and discuss.

I don't understand the Dojo documentation

I'm a beginner in dojo. First of all is everything javascript based? For example to create a form I have to use JavaScript or HTML tags?
Also I cannot understand their documentation and tutorials. It's very confusing.
Is there a proper website (other then dojo itself) that has good tutorials?
You can use Dojo's components's (widgets) in two ways. Programmatic and declaritive. The programmatic way (what you are talking about) is by defining widgets through the use of javascript. With declaritive you can define them using HTML markup. David Walsh has a nice short writeup and if you search for "declaritive programmatic dojo" you'll find some questions and answers on the matter:
https://davidwalsh.name/dojo-widget
Difference between programmatically vs declaratively created widgets in dojo?
Declarative coding or programmatic coding in Dojo Projects?
Declarative or programatic approach in DOJO?
If you're having trouble with the tutorials on the Dojo website, i suspect you're better off, first diving into some basic beginner javascript tutorials before trying to learn a framework like Dojo. I concur with the comment Ferry made on your question, there are no better resources than the actual Dojo website. I recommend following every tutorial, starting with the Hello Dojo tutorial and working your way up so that you don't miss out on the basic concepts which you'll need when you read the harder tutorials. Good luck!
For your first question: dojo is javascript-based platform that provide you with a basic javascript library and a bunch of basic widgets (UI controls like button, dialogue, layouts,...), and some extra things. However, you don't really have to use dojo all the time: you still can use dojo to manipulate a html form button; it's just dojo button comes with extra functionalities and might save you some time.
For the second question, I agree with iH8 that dojo website is the best place to start. There are three different ways dojo websites can help you:
Look at the tutorial: Basic steps on how to set it up and use provided functionalities as-is
Look at thetoolkit api: This provides a very detailed view of dojo javascript object (See what extra things you can do with dojo objects)
Look at the nightlytest: I found this very helpful in term of showing me what can be done outside of the tutorial (i.e. how to use things you found in the api)
Other than these, you can look at existing implementation to learn about the toolkit.
Basically, this is how I am learning Dojo. Without more-specific questions, it's hard to tell what is confusing about the tutorial. I would recommend you give it a try and post a question: everyone here will be willing to help you.
I recommend starting with some video tutorial like this.
When you understand the concept, you can try to copy and paste some code from Dojo documentation tutorials or Reference Guide, because all books are out-of-date.
Also you may find some useful information on IBM-related sites like http://www.ibm.com/developerworks because IBM invested in Dojo and uses it for its products.
If you have enough resources ($) you can take participation in Workshops (sitepen.com/workshops)

create cascading dropdown in library of sharepoint 2010

Can anyone tell how to create cascading drop down in the library of share point 2010 without the help of java script and info path designer.i am trying through java script techniques,but its not working properly and i don't want to use info path designer.please help.
Without JavaScript and Infopath, you're into custom server side code. Without jQuery/Ajax then it's going to be a very clunky interface with multiple posts and screen redraws.
You may not be having much success with JavaScript but I can attest to using the SPServices and jQuery to achieve some very competent cascading dropdown solutions in SP207/2010 successfully. Have a look Here, there's plenty of sample code and advice.
I've had decent luck with using a 'custom field type' for such problems, if you need this to all be on an out of the box form. If you don't need this to be on an out of the box form, then it's no different than any other ASP.NET cascading drop down.
I haven't used custom field types a lot, and I've found them a bit awkward to get started with, but they're not really all that complicated once you have the basic template as most of the information is static; you can just take an unrelated example from someone else and change the few bits that apply to you.
You can make a custom form for the content type (if Visual Studio is an option) and do it like in any asp.net applications.
See here an example: http://spcustomforms.codeplex.com/
spcascade.org provides best free solution which support multi level dropdown list with no limits.
It is javascript/jquery based solution with no page refreshes and involves only one look up list for multiple columns.
Saves data in single line text instead of Ids that are used by typical look up columns.
Very easy to use syntax too!
http://www.spcascade.org
I have a simple solution without any JavaScript code: Cascading Drop Down Lists in SharePoint. Let me know if it solves your problem.

How does Safari's reader feature work?

I want to add a similar feature to a tool I'm making. I'm interested in how it works code-wise. I want to be able get an html page and exclude all but the article.
The Readability project does something similar for chrome and iOS. I'm not sure how it detects the content automatically but I know that Readability has an API for people who want to integrate it's features. You might want to check that out.
http://www.readability.com/learn-more
If you're working with Ruby, you could use Pismo. It extracts an article from a given document.

Is there a Dojo calendar similar to the JQuery plugin FullCalendar?

I'm looking a Dojo based calendar that can display events spanning across days in a month view exactly like the JQuery plugin FullCalendar
I work primarily in Dojo and I don't want to load JQuery if I don't need to.
This thread is a bit old now but I wanted to raise that there's now a candidate widget written by me for dojo 1.8+ that does exactly what you need: https://github.com/damiengarbarino/dojo-calendar
I tried to use the dojoc project and finally developed my own widget.
It is heavily customizable, has mouse, keyboard and even touch support, right to left display support, date formatting, custom views etc.
Documentation is available at: http://livedocs.dojotoolkit.org/dojox/calendar
I've been searching for something similiar recently and the best I can find is the 'dojoc' library. It appears to have been apart of the full dojotoolkit at some point but I can't seem to find a whole lot of information on it.
A test page showing it is on the author's website here. The github page for it is here. So far my attempts to locally use it have failed miserably. It seems to be built against an older version of dojo as well since it hasn't been updated in a while.
Although the Dojo 1.8 calendar widget looks promising, the documentation linked here http://livedocs.dojotoolkit.org/dojox/calendar is not up to scratch. Possibly the widget itself is also not ready for general use.
For example, it is proving difficult to prevent a particular event from being edited.
I realise 1.8 is not out yet. I trust the calendar widget and documentation will be better by the time 1.8 is released.