Selenium IDE for Firefox not reading values from PHP report form - find

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?

Related

A way to refresh the page without resetting/clearing the forms on it

I'm working on a page with 9 inputs and js that performs logic on those inputs before submitting it. It's getting really annoying having to enter the information into the forms every time I want to see my javascript changes.
Is there a way to refresh the page without clearing the form?
P.S. I'm working in IE9+, Chrome, Firefox, and Safari.
Thanks in advance!
Apparently, there are few tools (if any) that do this (at least that I was able to find). I've found a way to do this by writing a script that hijacks the window event loop and stores all the input values in a stringified cookie. When you refresh the page, you can use window.onload to automatically repopulate the inputs.
If you (understandably) don't want to write your own script to do this, I've written one you are welcome to use on github.

web submission automation: simulate onclick event on a title element to load form

A resume-service I use requires that for each listed activity on the resume, there is an hours-per-week field and total hours field. However, the total hours field does not update itself automatically no matter how many weeks pass. My goal is to write a script that does this.
The idea behind the script is:
Log in to website -> go to a certain page -> submit a form** on that page updating the total hours
**unfortunately, for the form to open, you need to click an "edit" title element first which causes it to show up. I've taken a look at the html of the webpage but cannot find the form or input tags corresponding to the form I wish to submit, only that the form is generated with what I think is a javascript function call from the element's onclick field.
I believe the relevant html snippet is:
<a title="edit" class="edit" href="#entry-type" onclick="editComponent('10227041','education');">Edit</a>
but just in case there is a much larger code snippet later in this post (check the 2nd pastebin link at the bottom)
THE QUESTION: Is there a specific language/library/way (preferably in python, although I can work with Java) to simulate an onclick event and that would result in a form loading?
I've worked on this problem a bit, starting with python's mechanize library. I wrote two functions,
def login(br,url):...
def navigate(br,baseurl,url):...
which would satisfy the first two parts of my script's plan, but the third is where the trouble starts. When I print all the forms on the page using
for form in br.forms():
print form
I get http://pastebin.com/Gxy2tc1A
The website's html can be found on http://pastebin.com/PySri5cb
Later I tried to work with Selenium (the firefox IDE plugin) and then exporting code into python, where I would edit it to satisfy my specific needs, but that was a no-go either due to some awkward errors.
Have you looked into GreaseMonkey? You should be able to use that to extract the hours per week, do the math and populate the total hours field. You could probably do the entire thing. Anything that can be done on the page in JavaScript could be done within GreaseMonkey.
EDIT: The code for that site is awful. I especially like the inline call to loadResume() that is made BEFORE the element it writes to (#build-wrap).

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.

is it possible to interact with hidden elements in selenium2?

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?