Capybara nested_form Poltergeist select action - select

I'm using the fantastic nested_form gem to handle my nested attributes which works perfectly.
My problem occurs when i try to use Capybara/rspec with Poltergeist as a driver to run a few integration tests on my nested form's select field.
My test is as follows.
click_on "Add Field"
find('input:last').set "Employee Code"
find('select:last').select "Word"
I get the following error in rspec
Failure/Error: find('select:last').select "Word"
Capybara::Poltergeist::ObsoleteNode:
Capybara::Poltergeist::ObsoleteNode
When i print the html content before trying to find 'select:last', I'm able to see the correct html. Pasted below.
<input class="string required" id="source_model_attributes_attributes_1355377152026_field_name" label="Field Name" name="source[model_attributes_attributes][1355377152026][field_name]" placeholder="Field Name" size="50" type="text">
<select class="select required" id="source_model_attributes_attributes_1355377152026_field_type" label="Field Type" name="source[model_attributes_attributes][1355377152026][field_type]" prompt="Select Field Type">
<option value="">Select Field Type</option>
<option value="Word">Word</option>
<option value="Number">Number</option>
<option value="True or False">True or False</option>
<option value="Date & Time">Date & Time</option>
<option value="Date">Date</option>
<option value="Time">Time</option></select>
I'm using find, instead of fill_in as my html is generated dynamically with a timestamp attached to the id & name fields.
It might also be worth mentioning that I've had poor luck with Capybara's select Action which I tried to use like this.
select "Word", from: "Field Type"
Which fails with the error below.
Failure/Error: select "Word", from: "Field Type"
Capybara::ElementNotFound:
cannot select option, no select box with id, name, or label 'Field Type' found
Capybara, for some reason, is not able to find the label, maybe because it's hidden from the actual form.

Related

I want to have a select and input field in react with all the options in my JSON file or mongodb database

I have to provide a dropdown in my form with a large number of options in it but the selected options are to be shown at various places so i have to store the selected option or its id at database too.
<FormGroup>
<Label htmlFor="category">Category</Label>
<select innerRef={input => (this.category = input)} id="select" class="form-control" >
<option value="0">Please select</option>
<option value="1">Mobiles</option>
<option value="2">Television</option>
<option value="3">Washing Machines</option>
</select>
</FormGroup>
This is the gist of the form type i want, there will be other categories in somewhere around 25. I cant have 25 options opening in dropdown. I want to have something like select and input type in dropdown. Also i want to store the option selected by the user and then display it somewhere else.

AutoHotKey: How to get list of available values from drop down list?

I am trying to automate a website to get data. Usually if I know in advance what are the possible value from the drop down list, I can hard code them in my script.
But if I don't know what are the values, is there an elegant way to dynamically obtain the drop down list values?
Working sample from: https://autohotkey.com/boards/viewtopic.php?t=15574
select name="ConnectDTO.EvaluationGroupId" id="ConnectDTO_EvaluationGroupId" style="width: 260px;" required="yes" data-val-number="The field Evaluation Group must be a number." data-val="true"><option value="">Please Select</option>
<option value="4">ccpdmanagement</option>
<option value="7">AM Northern</option>
<option selected="selected" value="3">cwplanning</option>
<option value="1">mnplanning</option>
<option value="2">msplanning</option>
<option value="9">LCC</option>
<option value="6">powerquality2</option>
<option value="8">AM Southern</option>
<option value="5">tcoqueries</option>
</select>
When my script arrived on the page after loadIE(wb), is there a way to "get" the list of selection - such as ccpdmanagement, AM Northern etc...?
I know how to select them once the option is known in advance only.
pwb.document.getElementById("ConnectDTO_EvaluationGroupId").Focus()
pwb.Document.GetelementById("ConnectDTO_EvaluationGroupId").value := "1"
Thanks.
I found a solution here: https://autohotkey.com/boards/viewtopic.php?t=35467
Althought the Author stated he has a problem with the code (stated not work for some reason).
But for my purpose - to retrieve the list of all the drop down list option. It worked fine.
myDropDownList := wb.document.getElementById("your_dropdown_ID")
loop % myDropDownList.length
{
test := myDropDownList[A_Index-1].value
MsgBox %test%
}

JSP Dropdown from postgresql

I'm very very new to jsp and postgresql and I want to add a dropdown menu to my jsp file.
There is table with Names and Numbers and all I want is getting the names displayed in the drop down
This is what I got so far. An empty dropdown with the right numbers of rows (4 as I have only for rows in my table) is displayed but no names!
<sql:query
dataSource="${db}"
var="result">
select name from customer
</sql:query>
<select>
<c:forEach
var="result"
items="${result.rows}">
<option value=${param.name}>${param.name}
</option>
</c:forEach>
</select>
Thanks for any help in advance!
PS: i tried to find an answer but all the answers were about mysql but we are using psql :/
Your option list has the right number or options but they're empty because the variable param doesn't exist.
You have:
<c:forEach var="result" items="${result.rows}">
<option value=${param.name}>${param.name}</option>
</c:forEach>
var is the variable to be created from items, so you don't want it named the same as the items list. This is where you should be creating the variable param. It should be:
<c:forEach var="param" items="${result.rows}">
<option value='<c:out value="${param.name}"/>'><c:out value="${param.name}"/></option>
</c:forEach>
You should probably also do it like <option value='${param.name}'> since the field name is probably text rather than numeric.

Jeditable show always select box

i'm using the Jeditable plugin to send request to the server by changing the select box. my problem is, that i want to show the select box at any time, not only if the users (double)clicks the text. i did not found any option on the plugin site, so i ask you if there is another solution (for the plugin).
$('.col-type').editable( 'set-type.php', {
data: function(value, settings) {
return " {'1':'1','2':'2','3':'3', 'selected':'2'}";
},
onblur : "submit",
type : "select"
} );
Idea on inplace editing is to show the form only when you click element. If you always want to show the form use plain old html.
<select>
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
</select>

Populate and Update Form data in ColdFusion

I have a form the needs to be populated and and updated. There are several dropdown fields and input fields on the form that need to be populated and then allow the user to make a change if necessary. I have created queries to select the data, then I want to populate the form with the selected data but, allow a user to change the form fields. I have tried with the first field which is a dropdown field but, I receive an error saying that I can't nest two queries.
This is the error I received: A query driven cfoutput tag is nested inside a cfoutput tag that also has a query attribute. This is not allowed. Nesting these tags implies that you want to use grouped processing. However, only the top-level tag can specify the query that drives the processing.
Here is my code:
<cfoutput query="getinfo">
<select name="ProgramName" id="ProgramName" style= "font-size:24px">
<option style="font-size:24px" value = "0">--Program Name--</option>
<cfloop query="PName">
<option value="#ProgramName#">#ProgramName#</option>
</cfloop>
</select>
</cfoutput>
Here is my getinfo query:
<cfquery name="getinfo" datasource="dbotest">
SELECT ProgramName, TestName
FROM Programs
WHERE ProgramID = "D219"
</cfquery>
What you've posted is valid syntax for outputting a query.
<cfoutput query="getinfo">
<select name="ProgramName" id="ProgramName" style= "font-size:24px">
<option style="font-size:24px" value = "0">--Program Name--</option>
<cfloop query="PName">
<option value="#ProgramName#">#ProgramName#</option>
</cfloop>
</select>
</cfoutput>
If your page is set up like this, then that is invalid. You can simply change <cfoutput query="getinfo"> to be <cfloop query="getinfo">
<cfoutput>
<!--- other code --->
<cfloop query="getinfo">
<select name="ProgramName" id="ProgramName" style= "font-size:24px">
<option style="font-size:24px" value = "0">--Program Name--</option>
<cfloop query="PName">
<option value="#ProgramName#">#ProgramName#</option>
</cfloop>
</select>
</cfloop>
<!--- more code --->
</cfoutput>
(I know this isn't really an answer but should hopefully help clear things up.)