Selecting combo box values - javascript

I'm trying to implement a data driven test approach using Selenium (Python) but I've run into an issue selecting dynamic values from multiple combo boxes. I'm currently aware of one option, using method driver.execute_script("JAVASCRIPT TO GET COMBO BOX OPTION") but hard coding the values defeats the purpose of automated data driven testing. Is there any other solution?
P.S Please let me know if there is any additional info needed.
Thanks,
Eric

Don't do that.. that's bad.. don't delegate this to JS when Selenium can handle it just fine.
You can try something like -
el = driver.find_element_by_id('id_of_select')
for option in el.find_elements_by_tag_name('option'):
if option.text == 'The Option I Am Looking For':
option.click()
I can't find any documentation for it in Python, but there is a class named SElect which has a couple methods that you can use, like, select_option_by_visible_text

I think this should $("#id").val() give you the value i guess

Related

How to achieve suggestions in input field

Hi I had come across a question how to achieve suggestions in the input field while typing for example (in browser url bar while we typing first 3 to 4 letters it give suggestion if the url is correct we go with it else with single delete key press remove the suggested content). This need to be done with input field. Is this scenario is possible? Thanks.
There's a big range of possibilities here.
If the contents of the list are static or easily generated via code, you can use a native HTML <datalist> element.
If you are wanting autocomplete in the form using the user's previously-provided data, you can just enable via the <input autocomplete> attribute
If you're wanting far more customization, it's going to have to be some JavaScript that does the dirty work for you. Stack Overflow is not a good forum for getting library suggestions, but you should survey what's available in your current development stack.
This is absolutely achievable, have a look at - typehead.js
It's a javascript project for doing exactly what you're asking, I believe it's compatible with boostrap too.
Autocomplete suggestions are a very common Web Component. If you are using jQuery, you might want to try this component published by Materialize. If you are using, say, Polymer, you might want to try paper-autocomplete. If you are using vanilla javascript, you could try typeahead, or something like this autocomplete library. Most other modern web frameworks will have some alternative. I wouldn't really recommend making one from scratch.

Trying to create a edit in place style form in vue.js

This is my first attempt to create anything with vue.
Here's a quick JSFiddle demo
I'm trying to create a form that display the values without input, and then clicked, the input will display. I've managed to have a mockup "working", but I'm not very sure if this is the correct approach or not. I'm not very sure about:
Vue.nextTick(function() {
document.getElementById(field.id).focus();
});
On the other hand, is there a recommended input validation library or something?
I would really appreciate any guidelines here :wink:
Thanks!
Regarding you first question I don't think there is an issue with using plain javascript to focus on your input. You can also achieve this with vue refs
See updated fiddle
This doesn't look cleaner but with refs you can put what you want as a ref and you are not limited by ids and in the end it's your choice what to use.
Regarding validation libraries here are a few:
Vuelidate
Vee Validate
Other ones

Selectize Capybara acceptance testing

I am looking for some assistance with acceptance testing of the Selectize jQuery plugin using the Capybara test framework.
We are having a problem with the way Selectize lays out the HTML it generates, there is no definitive link between the select dropdown and the values contained within the dropdown
As you can see from my jsfiddle here : http://jsfiddle.net/et4t20wz/
$('.test').selectize({
create: false,
dropdownParent: 'body'
});
Viewing the source code, the containing div has the 3 selects within it and the values for the dropdown are contained within the body tag.
I need a way for our test team to be able to create a 1 - 1 connection between the two elements. So far we have come up with a rather weak connection, as we know the first Selectize values will be stored in the first div.selectize-dropdown we can use this logic to map to the first div.selectize-control
This is rather flimsy and probably not the best approach, but the best we can come up with thus far. We have found a few solutions on the web, but sadly they appear to be out dated or reliant on different DOM structures.
For example: http://climber2002.github.io/blog/2014/09/22/capybara-integration-tests-with-jquery-selectize/
Hopefully we are not the only ones to have come in contact with this problem and someone can offer some assistance / advice
Thanks in advance.
I believe the link is just positional in the html, the two divs that make up a a selectize control are inserted immediately after the select element that is converted. Therefore if you know the id of the original select you should be able to get the associated divs using the sibling selectors
page.find(:css, '#test + div.selectize-control + div.selectize-dropdown')
or
page.first(:css, '#test ~ div.selectize-dropdown')
if you've already clicked on the div.selective-control (or maybe the input in it) then the elements in the .selectize-dropdown should be visible and you can click on them
So we managed to fix this problem using a solution I found here :
Capybara integration tests with jquery.selectize
The code didn't really work, however. So I ended up using this script I wrote.
var selectize = jQuery('#key').selectize()[0].selectize;
jQuery(selectize.setValue(selectize.search('#value').items[0].id));

Disable li using Dojo

I am using dojo script to create custom dropdown list. when I create dropdown,
dojo.forEach(tags, function(tag) {
var option = dojo.create("option", {
innerHTML: tag.name
});
dojo.place(option, Select);
});
});
I create this drop-down to achieve the autocomplete.
Now the problem is I would like some of the opitions disabled, so user cannot select them.
how can I do this?
AFAIK and was trying there is not such a possibility. I think it makes very little sense to mix autocomplete with disabled values. Possible solutions:
Get rid of autocomplete feature and use dijit.form.Select or native Select, both works fine with <option disabled="true"></option>.
Use dijit.form.FilteringSelect and don't add or dynamically remove options you want to disable.
Please note that dijit.form.FilteringSelect and dijit.form.ComboBox are primarily designed to work with model based on API of dojo.data and from Dojo 1.7 also dojo.store. You should update Model (dojo.data/dojo.store) because View (FilteringSelect/ComboBox) is observing the model and updates UI when needed. See my jsFiddle examples.
N.B.: If you are not familiar with dojo.data API and you can use the latest version of Dojo don't bother to dive into dojo.data API and start with dojo.store. It's terribly wrong and complicated way to manage model via dojo.data.

YUI Checkbox Button - retrieving the checked value

(I've tried posting this on YUI message group but without any luck)
Can anyone tell me how to retrieve the checked state of a yui Button? I've tried by creating the Button in code, which is then outputted as a HTML button but this only changes the title attribute.
When I use checkboxes instead, none of the checkboxes are checked (when iterating through them with jQuery).
Is there an easier way of doing it? Say with the 3.0 Node API, or Element?
EDIT:
To clarify how this problem came about, I'm using the YUI ASP.NET controls. They add controls to the page like this
Sys.Application.add_init(function() { $create(YUIAspNet.Button, {"ButtonID":"yuiMyButton_btn","ButtonName":"yuiMyButton$btn","TabIndex":0,"ButtonType":"checkbox","Text":"Technology"}, null, null, $get("yuiMyButton"));});
So as you can see, finding all buttons is not as simple as I'd like it to have been.
Sorry are you talking about checkbox buttons? Use:
myButton.get("checked")
where myButton is an instance of YAHOO.widget.Button.
Chris, I am the starter of YUI ASP.NET project. I watch the YUI mailing list regularly, I must of missed your question.
I have a more general answer for you and anyone else having the problem and ending up reading this, not just for checkbox button, but for all controls.
On the client, you can have access to the YUI object by calling the .get_YUIControl() method on the custom wrapper client object, then you have the control over the original YUI object. The YUI documentation is very good, and you can find a good description for what you'd like to accomplish.

Categories

Resources