How to read values from input tag when using jwebunit - jwebunit

I need to read the values from a series of input tags of a html page.
Can anyone help me in this regard?
Thanks in advance..

One can get the value of input tag in a web page when using JWebUnit in the following way..:
getElementAttributeByXPath("table//tr[2]//td[2]/input[1]","value")
It gives the value of value attribute of input tag.

Related

How to set value into input field where placeholder contains "email"

Ques: How to set value into input field where placeholder contains "email" using nightwatch.js ? Please explain
This should do the trick:
browser.setValue('input[placeholder="email"]', 'someValue');
The api reference can be somewhat helpful to figure out stuff like this on your own.
browser.clearValue('input[placeholder="email"]');
browser.setValue('*Updated css locator of email field*', 'someValue');
There is another one way to set value in input by using JS jQuery:
Chrome DevTools Console: var email = jQuery("#email");
email.val('test');
NightwatchJS: browser.execute("jQuery('#email").val('test')");
or
browser.execute("document.querySelector('#email').setRangeText('test')")

In a rails app, when using Jquery Token Input, how to pre-populate data when the form is reloaded?

In my form, I use JqueryTokenInput to add tags. When I fill the form and submit, usually, if there are errors the form will load again with the values I entered. But the TokenInput field won't get those values. I tried to do it by loading data from the params like this :
In the view input field :
data: {load: #current_tags}
In the controller :
#current_tags = params[:deshana][:deshanatag_list]
This doesn't work. I think its not in the right format. How can I do this?
Buddy i have also used the token input for the auto-complete drop down and here i have doing this which you have asked the question.
May this will defiantly help full for that to compelete your problem.
Write the following line in the start of your javascript tag on the html page.
$("#id_of_your_token_input_field").tokenInput(token_input_data,{
prePopulate: [{id: id_of_data, name:name_of_data}]
});

Creating a text area that accepts html as input in ruby on rails

I am new to rails.I want to create a text area that will accepts html as input and can process them as well.
I dont know how to do this .I am using formtastic gem for my form.
Please help me out.
thanks in advance.
If you type any valid html on your text area, save, and then show the string with html_safe method, it should parse the html as usual.
Example: "<b>Hello bold</b>".html_safe should render Hello bold on the screen.

can we write javascript code in jsp which is of with struts html tag library

this is phani kumar,
Actually, i am writing one page to show product details. In that i written code to display the
productid list in jsp page with the help of and tags
. but the main problem is, based on the selection of productid, i trying to show the product details(productname, productcost, productstock..like).But i am facing problems to work this.
I am trying it with javascript, but because of struts html taglibrary, i am getting problems here, could u please give me solutions to resolve this problem anyone.
and can anybody tell how to get dropdown selection value into javascript(if we are using tag library in struts)
How are you using javascript to create your view? You should be able to use
<logic:iterate>
to traverse your product collection, then
<bean:write .../>
to display information from each product.
<html:select>
will create a dropdown in your form. Use
<html:option>, <html:options>, or <html:optionsCollection>
to populate each item in the dropdown.

Generate URL client-side for jQuery Grid from json field?

We are using Struts 2 and want a jQuery Grid showing a list of accounts. When a user clicks an account we want to take them to a page specific to that account.
At this point I'm looking for suggestions as to the best way to do this. Currently I'm building a URL server side which I then return but this isn't optimal since I don't have access to <s:url>.
One idea I've had is to combine <s:url> and each row Id on the client side but I haven't found a way to do this. Is there a grid would that allow this? or a better way?
Updated Explanation Attempt:
I am returning a json list to jQuery grid. One column in the grid is a url but I can't build that in the service level. Instead I'd love to have a way to use <s:url> when my json results are returned. Is there anyway to do this?
You cannot use <s:url> client side.
The Struts2-Tags get used serverside
to generate the HTML, so there's
basically no difference if you
construct them yourself or let JSP
construct the HTML.
There's the struts2-jQuery Plugin and with it the jQuery grid plugin. Find out more about it here:
https://code.google.com/p/struts2-jquery/
If you know the actionName and have the ID in the list you're iterating over, you can just code the necessary link yourself (if the object in the list has a getter named getId()):
<a href="http://host:port/webapp/actionName?id=<s:property value='id' />">
Hope that helps, if not please show the code of the page and / or dredefine your question.
There isn't a really straight forward way. Here is the answer to "Struts2 URL buiilding in action for JSON" answered on the struts mailing list:
http://old.nabble.com/Struts2-URL-building-in-action-for-JSON.-td30487914.html
If you get a chance let me know how you implement this.

Resources