Jquery + Selenium (PHP) - Urgent :(

66 views
Skip to first unread message

Andre Almeida

unread,
Jun 4, 2012, 8:44:06 AM6/4/12
to seleniu...@googlegroups.com
Hi!

I've one PHP method that runs a jQuery function and works 100%

function getTopProduct()
{
$top_product_id = $this->getEval('var window = this.browserbot.getUserWindow();
window.$(".parent:first").attr("ID")');
return $top_product_id; 
}

but now, i wanna make another function that execute other jQuery script, but in that script i had to create a new jQuery function.
I tried many ways to execute that scripts with no success...

So, i would like to know if anyone have any idea how to run jQuery scripts that have new jQuery functions.

I am desesperated, because is an essencial module of my selenium tests.

This is the function i wanna implement.

function getRequisitionNumber()
{
// Number of products in requisition after delete
$requisition_number = $this->getEval('var window = this.browserbot.getUserWindow();
window.get_max_order_id();
function get_max_order_id()
{
var A_childs_tr = $(".requisitionstable tr.child");

var max_order_id = - 1;

A_childs_tr.each(function(index, order_tr)
{
var order_id = $(this).attr("ID").split("_");

if ( order_id[1] > max_order_id )
max_order_id = order_id[1];

});
return  max_order_id;
}
');

}

Andre Almeida

unread,
Jun 4, 2012, 10:08:22 AM6/4/12
to seleniu...@googlegroups.com
barancev help me with some tips in IRC.

Here my solution:

function getRequisitionNumber()
{
// Run script to "create" function
$this->runScript('function get_max_order_id()
{
var A_childs_tr = $(".requisitionstable tr.child");

var max_order_id = - 1;

A_childs_tr.each(function(index, order_tr)
{
var order_id = $(this).attr("ID").split("_");

if ( order_id[1] > max_order_id )
max_order_id = order_id[1];

});
return  max_order_id;
}');
// Get requisition number 
$requisition_number = $this->getEval('var window = this.browserbot.getUserWindow();
window.get_max_order_id();');

return $requisition_number;
Reply all
Reply to author
Forward
0 new messages