In a previous script step, I updated the Previous Year Sales and am trying to confirm that the Gross Margin Dollar was correctly auto-updated to 650000. I am getting an error that watir is :
unable to
locate element using id => "GrossMarginDollar", :tag_name => "input".
In a previous question, there was an answer that if there are multiple same-name elements, in this case span3, that watir picks the first one in the html, not the first one visible. If this is the problem, how can I specify which
span3 to use? If this isn't the issue, what should I be using to confirm the value was updated?
Here is the watir script:
confirm = browser.div(:id => "target_modal").div(:class => "modal-body").div(:class => "row").div(:class => "span3").input(:id => "GrossMarginDollar")
puts confirm.value.include? '650000'
Here is the html:
<div class="row">
<div class="span3">
<label for="FirstName">First Name</label>
<input id="FirstName" type="text" data-bind="value:FirstName" />
<label for="LastName">Last Name</label>
<input id="LastName" type="text" data-bind="value: LastName" />
<label for="Email">Email</label>
<input id="Email" type="text" data-bind="value: Email" />
</select>
</div>
<div class="span1"></div>
<div class="span3">
<label for="PreviousYearSales">Previous Year Sales</label>
<input id="PreviousYearSales" type="text" data-bind="value: PreviousYearSales" />
<label for="GrossMarginDollar">Gross Margin Dollar</label>
<input id="GrossMarginDollar" type="text" data-bind="value: GrossMarginDollar" />
</div>
</div>
You are right in that Watir is only checking the first div with class 'span3', which does not include the desired input field.
You can specify which match to use (ie the second match) but using the :index property. Note that the :index is 0-based, so "1" is actually the second matching div.
confirm = browser.div(:id => "target_modal").div(:class => "modal-body").div(:class => "row").div(:class => "span3", :index => 1).input(:id => "GrossMarginDollar")
puts confirm.value.include? '650000'
However, I think you are over specifying how to locate the element. In general, you want to use as little information as possible (as it makes the locator more robust to changes). In this case, you have an id of the input element. Given that the id should be unique, you should not need all of the other stuff. Simply do:
confirm = browser.input(:id => "GrossMarginDollar")
puts confirm.value.include? '650000'
Related
I am trying to add a class to my div if there is an error in the ModelState. Is there any way to achieve this?
This is how the Html looks like:
<div class="form-group">
<label class="control-label" asp-for="Vorname">Vorname</label>
<input type="text" class="form-control" asp-for="Vorname">
<span class="form-control-feedback" asp-validation-for="Vorname"></span>
</div>
Now I would like to add the class has-danger to the div arround it if an error occured on the Vorname property. Like this:
<div class="form-group has-danger">
<label class="control-label" asp-for="Vorname">Vorname</label>
<input type="text" class="form-control" asp-for="Vorname">
<span class="form-control-feedback" asp-validation-for="Vorname"></span>
</div>
Edit:
If your form is submitted to the server with no prior on-the-client JavaScript validation (old school! but it works), then you’ve got yourself the easiest of all fixed. You can just add these CSS classes whenever the page loads in the following fashion:
$(document).ready(function() {
$('.input-validation-error').parents('.form-group').addClass('has-danger');
});
I have a rails code like below for input fields.
Name:-<%=text_field_tag "specification[name1]","",:class=>"autocomplete form-control"%>
<br/>
Value:-<%=text_field_tag "specification[value1]","",:class=>"autocomplete form-control"%>
I want a name and one value to be aligned horizantally to each other.
Not sure how do I go about it. I hope the question is clear.
Thanks
There are millions of ways to do this but simplest one is to use them in a table:
<table>
<tr>
<td>Name:-<%=text_field_tag "specification[name1]","",:class=>"autocomplete form-control"%></td>
<td>Value:-<%=text_field_tag "specification[value1]","",:class=>"autocomplete form-control"%></td>
</tr>
</table>
Since you are already using bootstrap, you can use the form-inline class available in bootstrap and then use a form-group class for each label and field. Just add the form-inline class to the form tag.
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">Name</label>
<input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
</div>
<div class="form-group">
<label for="exampleInputEmail2">Email</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe#example.com">
</div>
This will show the two fields inline.
You can you it in this way as given in the bootstrap documentation.
I'm pretty new to using wufoo forms and have been searching for a few days and can't quite find what I'm looking for.
I did find a number of articles about 'URL Modification' but not sure how to implement this for what I need.
We have a simple single wufoo form which is being used across 6 iterations of a client's domains (they are sector specific).
We want (in the email notification and response entry on wufoo) to record which site was used to complete the form (for analytical purposes).
In other words the email to the client should list:
Name: John Smith
Email: Johnsmith#mail.com
Phone: 555-123-1234
From: www.websiteversion1.com
The form is being integrated on Wordpress sites.
Any help would be appreciated!
You can copy the form HTML to your site's templates and modify the form, using PHP to fill in the value of the site url. I don't think WuFoo will automatically fill that field in for you.
First of all, in your WuFoo account forms manager, add a website (url) field and make it visible for admins only (this is a Wufoo option).
Then copy the generated form into your own template.
Now modify your form template so that it grabs the site URL and fills it in for the value of the website field where you want it.
Your form template might look something like this:
<form class="wufoo-form" id="form3" name="form3" accept-charset="UTF-8" autocomplete="off" enctype="multipart/form-data" method="post" novalidate action="#">
<div class="form-group">
<label for="Field1">Name</label>
<input id="Field1" name="Field1" type="text" placeholder="" value="">
</div>
<div class="form-group">
<label for="Field2">Email</label>
<input id="Field2" name="Field2" type="email" placeholder="" value="">
</div>
<div class="form-group">
<label for="Field3">Phone</label>
<input id="Field3" name="Field3" type="tel" placeholder="" value="">
</div>
<div class="form-group hidden">
<label for="Field4">From</label>
<input id="Field4" name="Field4" type="url" class="form-control" placeholder="" value="<?php esc_url( home_url() ); ?>">
</div>
<div class="form-group">
<button id="saveForm" name="saveForm" type="submit" name="submit" class="btn btn-primary btn-lg">Let's talk!</button>
<input type="hidden" id="idstamp" name="idstamp" value="***the_id_for_your_form_wufoo***" />
</div>
</form>
I'm having some problems with the bootstrap forms. For some reason they all get messed up.
This is what it should look like:
http://i.imgur.com/vjCZvwc.png
This is how it shows up on my page:
http://i.imgur.com/48qtLc7.png
As you can see, it makes the input box smaller and it places 'br' code behind every line. It also puts a random 'p' in it without any closing tag. (nowhere to be found on the page)
My input code:
<form>
<fieldset>
<legend>Legend</legend>
<label>Label name</label>
<input type="text" placeholder="Type something…">
<span class="help-block">Example block-level help text here.</span>
<label class="checkbox">
<input type="checkbox"> Check me out
</label>
<button type="submit" class="btn">Submit</button>
</fieldset>
</form>
The output code in the browser:
<form>
<fieldset>
<legend>Legend</legend>
<p>
<label>Label name</label><br />
<input type="text" placeholder="Type something…"><br />
<span class="help-block">Example block-level help text here.</span><br />
<label class="checkbox"><br />
<input type="checkbox"> Check me out<br />
</label><br />
<button type="submit" class="btn">Submit</button><br />
</fieldset>
</form>
So my question is; What could possibly be causing this and how do I fix it?
I'm using Bootstrap v2.3.2 as a theme on wordpress and followed this tutorial, so most of my code looks like it.
blog.teamtreehouse (dot) com/responsive-wordpress-bootstrap-theme-tutorial
Thank you for taking the time to read this. :)
This is not a problem with Bootstrap, but with your WordPress editor (or how you're using it).
You'll need to use a plain text editor or reconfigure what your editor does to HTML on save.
I'm designing dynamic forms for grails and I was wondering if it was at possible to set the widget constraint dynamically?
Setting the widget constraint is not the way to attack this. I suppose the simplest method would be to choose the tag you'd like to display based upon some condition using an "if" tag in your view or template. For instance:
Say you have a Book
class Book {
String name
}
If you use Grails generate-view for this class, Grails will produce a template called _form that looks like the following:
<div class="fieldcontain ${hasErrors(bean: bookInstance, field: 'name', 'error')} ">
<label for="name">
<g:message code="book.name.label" default="Name" />
</label>
<g:textField name="name" value="${bookInstance?.name}"/>
</div>
You can test your condition in this form and change the view:
<div class="fieldcontain ${hasErrors(bean: bookInstance, field: 'name', 'error')} ">
<label for="name">
<g:message code="book.name.label" default="Name" />
</label>
<g:if test="$yourCondition">
<g:textField name="name" value="${bookInstance?.name}"/>
</g:if>
<g:else>
<g:textArea name="name" value="${bookInstance?.name}"/>
</g:else>
</div>
Now the view will display a textField or textArea field based upon $yourCondition.