is it possible to interact with hidden elements in selenium2? - element

I need set value in Hidden inputfield of my webpage, I am using Selenium 2.
I tried with webelement.sendKeys(value), but its not working.
Can anybody tell me how to do this ?
Thanks.

That question seems a little bit out of the box. Selenium is simulating user-based interactions. So, that's pointless to expecting from a user editing hidden elements on the page. But may be you should say why do you need this and what are you trying to do with this function, it can be more easy to finding some workarounds for it.

You can't modify the hidden object using element methods. Instead, send script to the driver:
#driver.execute_script("document.getElementById('context-menu-upload').value=#{value}")
Here is the documentation: execute_script(script, *args)
To use xpath instead, try this:
Is there a way to get element by XPath using JavaScript in Selenium WebDriver?

Related

Selenium IDE for Firefox not reading values from PHP report form

I have report forms in PhP and I need to read the elements on it, but the tool is not reading the values to validate it.
When I hit 'Find' button the tool is able to read the value, but when I run the whole test case, its not.
Please help.
Perhaps the page isn't fully loaded before you try to read the value?
Can you waitForElementPresent for that element?

Script to fill browser form

I have little business problem, I need to make a script to fill (not send) out browser forms(only simple textfields, checkboxes and drop downboxes).
I need to launch multiple windows with the same form with different data to speed up form filling
What kind of scripting/programming do I need to use to fulfill these needs(Batch, JS .. ) ?
I have knowledge only of java, and basic html,c,c++ ... so if I can get basic tutorials I would be grateful indeed.
I have bits of ideas of how this is possible - through IDs of various field on the page which I can access to edit their values, so I just need language specific tutorials/suggestions.
Batch would be preferable if possible, because i need to execute the script through a java swing program.
P.S : If this is of any relevance, only browser acceptable is IE
dont think its possible through Batch,
I think easiest would be javaScript for this task. (chill js is pretty easy)
You can write a simple javaScript to fill in form
You should find how to fill form through javaScript helpful
Then you can use ScriptEngineManager to execute javaScript from your java code.
This tutorial should be helpful :execute javascript from java
You can't fill HTML-fields with a Batch-File. The easiest way is to use Javascript an Greasemonkey in Mozilla Firefox. You can find Tutorials here.
An other way to send data to an WebServer is to use in C/C++/Java Sockets and the HTML-Protocol.

Chrome: Fill out same form many times for testing

Is there some kind of tool (ideally for Chrome) in which I can fill out a long form that I am designing/testing many times?
I should be able to:
Fill out everything once and save it
Fill in the saved form with one button click
Fill out the form differently and save it as a different "profile"
I'm testing some things manually during development so I don't want a fully automated solution for this (I am using Symfony2.1 so I can write functional tests also). I just need a way to quickly fill out the form so I can save myself some time but I haven't been able to find a good Chrome extension or anything to do it. I remember Firebug in Firefox having something like this I think (I never used it though) so I imagine something exists.
The built in saved forms don't seem to be as useful for this task but maybe I'm missing something.
You can check out iMacros for Chrome:
https://chrome.google.com/webstore/detail/imacros-for-chrome/cplklnmnlbnpmjogncfgfijoopmnlemp
Call it a rudimentary answer, but I believe the button shortcuts in Chrome accept Javascript. I've done this with FireFox by doing something like:
javascript:document.formname.fieldname.value='value';document.formname.fieldname2.value='value';document.formname.fieldname3.value='value';return false;
There are some plugins. I used the below one, and it can satisfy your requirement.
This extension allows you to fill all form inputs with dummy data.
https://chrome.google.com/webstore/detail/form-filler/bnjjngeaknajbdcgpfkgnonkmififhfo
Here this one is for storing the form data and reusing it later. plugin populates with the data saved later when you want to fill it again.
https://chrome.google.com/webstore/detail/simple-form-filler/hbgbedpagfcecmjmlfpndghfclhnmmll/details
Hope this helps
This isn't an extension, but I've always found the easiest way to test a form is with a little jQuery.
I put a link under the submit button:
fillform
Then I fill the form with jQuery.
$('#fill_form').click(function(event) {
$("#name").val("Phoney Phoneyman");
$("#phone").val("555 867-5309");
$("#email").val("phoney#baloney.com");
$("#password").val("123456");
$("#password_conf").val("123456");
});
It takes about as long to do this as it does filling out the form initially and saves a ton of time. A tiny bit more work and you could generate random values - or values from a list.
Just remember to delete it all when you're done.
Google's form filler is just always incorrect enough to create work rather than save time.
Best form fill up extension ever is JunkFill.
I love it.
There is now a Selenium extension for Chrome. Selenium is one of the most popular webdrivers, I've used this as well, and even though there are a few oddballs in there, it works well generally:
https://chrome.google.com/webstore/detail/selenium-ide/mooikfkahbdckldjjndioackbalphokd?hl=en
I have made a chrome extension which exactly matches your needs, it may be worth a try - SimpleFill.
It's really simple and is available for Chrome, Opera, and Firefox.
Another useful chrome extension Formbot. When set to randomly fill the inputs, it will fill them with valid data.
You can check the Bug Magnet Chrome extension.

selecting the right element using jquery

Starting from the solution provided by the Nick Caver I wish to save some inputs provided by the users into a db. The problem is that I don't know how to select the right input from the current dialog box, using jQuery.
Here is my working code.
I've solve it. I had to use :last selector. I think is a good solution.
What do you think? I'm new in jQuery

How can I display another form in a z3c.form button handler?

I have a form with a single text field.
On submit I would like to display another form.
I can use RESPONSE.redirect() and pass it in the query string but I would rather not.
I don't want to use a SESSION variable.
I would like to display a second form which can read this value from the request variable.
I have looked at collective.z3cform.wizard but it is not obvious how to do this.
Trying to call the view() from the button handler does not seem to have any effect.
I fall in the same lack of functionality.
For what I know, z3c.form does not support this kind of traversing.
You may remember that this functionality worked well with CMFFormController.
Actually to do this, cmfformcontroller used session machinery.
So, you don't want to use session but that's the way. At least I do so, and I'm happy.
In this way there's no need of a wrapping tool like z3c.form.wizard.
hth,
alessandro.
collective.singing has a non-session based wizard which uses hidden fields to store results of intermediate steps.