Using Selenium to test jQuery () element data?

Can selenium be used to check if jQuery () element is set on an element?

In my application, the user enters information about several orders. Each order is added to the overview table so that they can see their progress along the way. In addition to the information about the visible order, we save some additional information that we need for each order, using the array stored in jquery.data (), for example:

$('#table').data('orders').push(neworderdata) 

I would like to write a selenium test to assert that when a user clicks โ€œAdd orderโ€, my additional data is added to $ ('# table'). data ('orders').

I think I need something like:

 Command: assertEval Target: $('#table').data('order')[1].cust_no Value: 99999 

But I think the problem I am facing is that the Selenium IDE does not know about jQuery namespace and functions, so it does not know how to find the table. But even if I used getElementbyID ("table"), how do I know what selenium knows about data ()?

+4
source share
2 answers

Are you sure the Selenium IDE has problems with $ ? I was able to access it from the Selenium IDE. Perhaps something else is broken in you by the jQuery expression? You can try "assertEval $ 0" etc. first, to see if the IDE can only evaluate $ ?

+1
source

I find that selenium will only see the jquery function if you access it as:

 window.$(...) 

not like

 $(...) 

Perhaps this (part) of the problem?

+1
source

All Articles