WWW::Selenium to capture component refresh - perl

I am writing a perl script using WWW::Selenium module to automate a website.
I am not at all a web development guy and have no idea about web technologies.
Let me try to explain the issue in layman terms.
I am dealing with a webpage, which has an order form with a button.
When I click the button, there is no page submit, but the button label changes.
Say for eg, the button goes through these changes when clicked multiple times.
Get Quote --> Order --> Confirm Order
Each time I click the button, there is no page refresh, but the button label keeps changing as above.
The id of the button is the same throughout, only the class changes.
How can I do this in WWW::Selenium?
Presently I am using wait_for_page_to_load(5000) after each click.
But the click is not having any effect on the label and I get error that timed out after 5000s.
Should I be using some other function to wait?

You could do something like this
$sel->wait_for_text_present_ok("Your text","time to wait","The message to display if this fails");
and an example below-
$sel->wait_for_text_present_ok("Order Confirmed","9000","The order was successfully placed");

Seems like you could use
$class = $sel->get_attribute($attribute_locator)
where the $attribute_locator is the button#class with button being the element locator that you clicked. Check if $class is the class you expect.

Related

how to submit after filling out a form with mechanize

What I am trying to do is really simple. Here is the code:
import re
from mechanize import Browser
br = Browser()
br.open("http://adreskodu.dask.gov.tr/" )
br.select_form( nr = 0 )
br.form.set_value(['1'],name='tip')
br.submit()
As you can see, the website first shows up with two radio buttons, and then after selecting the left radiobuttion via the br.form.set_value call and submit, I expect to access the new forms with mechanize that would appear normally if you were doing this on a browser.
What I would expect is a new form with more controls (if you go to the website and click on the left radiobutton, you will see what i am talking about).
However, I either dont do the submit correctly or don't know how to access the newly generated form that just came into being after clicking the very first radio button.
Ideally, i would want to re-find the newly created form and select the drop down menus and such. Is this a javascript issue I am encountering?
Thanks

"Send" button popup not appearing correctly

I'm using the Facebook Like/Send buttons along with dynamically generated HTML (loaded via AJAX requests). I've found that even though the Send button works fine when the element exists on page load, dynamically created Send buttons aren't working correctly. Clicking the button activates it and the button greys out, but the popup doesn't appear.
Here is a demonstration of what is happening: http://jsfiddle.net/Daniel15/VxpSj/
Any suggestions?
Thanks!
Yes, I can confirm the problem from your fiddle.
function addLikeButton()
{
// […]
FB.XFBML.parse(newEl);
document.getElementById('container').appendChild(newEl);
}
For some reason, this seems to be “the wrong way around”. Reverse the order of these two lines – put the new element into the DOM first and let FB.XFBML.parse parse it afterwards, then (from my test with your fiddle) it seems to work in the desired way.

mimic pressing a button on a webpage in the backgroud, for triggering an action

Pretend you have a button on an iOS GUI. Pressing this button should now trigger a button on a webpage (which triggers an action). While doing this, the webpage should not be visible. How can I do that?
My guess is, that I read and parse the webpage, and if I've found the button action, I would trigger it somehow. Since I'm not a web programmer, I wonder how to proceed or read on for such a task.
I need this task, because there is no JSON or XML webservice on the page that would make life easier.
Many thanks for any input
Okay, let's say you've already loaded your webpage in an off-screen (or hidden) UIWebView, and the submit button on that webpage looked a bit like the following in code:
<form id="my_submit_button" etc... >
Just call the following:
NSString* javascript = #"document.forms['my_submit_button'].submit();";
[myUIWebView stringByEvaluatingJavaScriptFromString: javascript];
Hope this helps!

lift disabling back button actions

I'm creating a transaction related site using lift. In here, there's a requirement to show a success page after the user action.
when i make action happen and press the browser's back button. it again goes to the previous page(before transaction page) making the transaction doable again. I need to limit this behavior. Is there any way of limiting the access to previous page by browser back button in lift.
There is no way to reliably stop the user from returning to the URL, but you can stop them from invoking the action more than once. Take a look at S.oneShot. From the Scala Doc:
All functions created inside the oneShot scope will only be called
once and their results will be cached and served again if the same
function is invoked
If you wrap the function that occurs when the button is pressed, even if the user does return to the page and click the button a second time, the body of the function shouldn't be invoked again.

How to create a "New xxx" popup?

I have a Grid object and added a [ (+) New Client ] button which I'd like to open a popup form to create the new client with a couple fields.
I've looked at the code examples in the website but haven't found how to do it (sorry if I've missed something).
This is the current page code:
function page_clients_listing($p){
$g = $p->add('Grid');
$g->addColumn('text','first_name');
$g->addColumn('text','last_name');
$g->addColumn('inline','telephone');
$g->addColumn('expander','comments');
$g->setSource('client');
$g->addButton('With Icon')->set('Add New Client')->setIcon('Plus');
}
Thanks in advance!
You can either create a popup or a dialog. Dialog is based on jQuery UI dialog implementation. Popups are likely to be blocked and are harder to control.
This is actually working for any object (you can apply to view, button, image, icon, etc), but I'll use button).
$b=$g->addButton('Add New Client')->setIcon('Plus');
$b->js('click')->univ()->frameURL($title,$url);
// OR
$b->js('click')->univ()->dialogURL($title,$url);
$url would most likely be returned by api->getDestinationURL(). The other page would be loaded and scripts on that page will be evaluated. Let's say you are on other page and now need to close the window.
$result = $this->addButton('Close')->js('click')->univ()->closeDialog();
closeDialog() returns a jQuery chain object pointing to a view which originally opened the frame. As a result if you do $result->hide(); then after dialog is closed, the original button ('add new client') will also be hidden.
Here is example to show some additional things you can do with frames, reloading and custom event handlers:
http://agiletoolkit.org/example/refresh1