- ArchanaRegular Participant
- Posts : 33
Join date : 2009-08-21
how to store number of rows of a table
Fri Aug 28, 2009 9:01 pm
I have a table, how can I store number of table rows in an element through IDE command?
Also I want to locate the table, but not through xpath here, becoz my page design may change later, but I know the table title which is fixed. After this text, I have a table. I want to know the reference of this table. (this table has no id)
something like
[<]span id="text"[>]table title[<]/span[>]
[<]div[>]aaa[<]/div[>]
[<]table[>]
[<]tr[>] [<]td[>]xxx []td[>] []tr[>]
[<]tr[>] [<]td[>]yyy []td[>] []tr[>]
[<]/table[>]
I want to know the no.of rows as 2.
Is it possible?
Also I want to locate the table, but not through xpath here, becoz my page design may change later, but I know the table title which is fixed. After this text, I have a table. I want to know the reference of this table. (this table has no id)
something like
[<]span id="text"[>]table title[<]/span[>]
[<]div[>]aaa[<]/div[>]
[<]table[>]
[<]tr[>] [<]td[>]xxx []td[>] []tr[>]
[<]tr[>] [<]td[>]yyy []td[>] []tr[>]
[<]/table[>]
I want to know the no.of rows as 2.
Is it possible?
Re: how to store number of rows of a table
Mon Aug 31, 2009 12:28 pm
hi,
you can use the following command to get the total row numbers:
storeElementIndex ( locator, variableName )
Get the relative index of an element to its parent (starting from 0). The comment node and empty text node will be ignored.
Arguments:
* locator - an element locator pointing to an element
* variableName - the name of a variable in which the result is to be stored.
Returns:
of relative index of the element to its parent (starting from 0)
For example use the following link:
http://clearspace.openqa.org/message/65957#65957
Best of luck.
bye
you can use the following command to get the total row numbers:
storeElementIndex ( locator, variableName )
Get the relative index of an element to its parent (starting from 0). The comment node and empty text node will be ignored.
Arguments:
* locator - an element locator pointing to an element
* variableName - the name of a variable in which the result is to be stored.
Returns:
of relative index of the element to its parent (starting from 0)
For example use the following link:
http://clearspace.openqa.org/message/65957#65957
Best of luck.
bye
- ArchanaRegular Participant
- Posts : 33
Join date : 2009-08-21
Re: how to store number of rows of a table
Mon Aug 31, 2009 7:55 pm
Hi,
could you expalin in detail?
storeElementIndex ( locator, variableName ) is not working for me.
storeElementIndex | //table[3]/tbody/tr/td[2]/table[2] | variableName
If I access ${variableName} is giving 4, but the no.of rows is not 4.
Please help.
could you expalin in detail?
storeElementIndex ( locator, variableName ) is not working for me.
storeElementIndex | //table[3]/tbody/tr/td[2]/table[2] | variableName
If I access ${variableName} is giving 4, but the no.of rows is not 4.
Please help.
Re: how to store number of rows of a table
Wed Sep 02, 2009 6:43 pm
hi,
how many row you have in that table?
how many row you have in that table?
- ArchanaRegular Participant
- Posts : 33
Join date : 2009-08-21
Re: how to store number of rows of a table
Wed Sep 02, 2009 6:47 pm
12, but I'm not getting 12.
I was using
store | javascript{document.getElementsByTagName('table')[5].rows.length} | size, but this is also not working.
I was using
store | javascript{document.getElementsByTagName('table')[5].rows.length} | size, but this is also not working.
Re: how to store number of rows of a table
Thu Sep 03, 2009 6:08 pm
hi,
Use xpath instead of DOM locator to get table row and column.
Syntax for table row
storeXpathCount | //table[@id='form1:dataTable1']/tbody[@id='form1:dataTable1:tbody_element']/tr | row |
Note: This will not count header of table in which heading for each column define.
Syntax for table column:
storeXpathCount | //table[@id='form1:dataTable1']/tbody[@id='form1:dataTable1:tbody_element']/tr[2]/td | col|
Note: the above command will give you the column present in row 3
Try this and will work fine. Best of luck.
Use xpath instead of DOM locator to get table row and column.
Syntax for table row
storeXpathCount | //table[@id='form1:dataTable1']/tbody[@id='form1:dataTable1:tbody_element']/tr | row |
Note: This will not count header of table in which heading for each column define.
Syntax for table column:
storeXpathCount | //table[@id='form1:dataTable1']/tbody[@id='form1:dataTable1:tbody_element']/tr[2]/td | col|
Note: the above command will give you the column present in row 3
Try this and will work fine. Best of luck.
- ArchanaRegular Participant
- Posts : 33
Join date : 2009-08-21
Re: how to store number of rows of a table
Sat Sep 05, 2009 12:18 pm
Yes, it's working fine
- rohitnirantar
- Posts : 4
Join date : 2010-09-14
Re: how to store number of rows of a table
Wed Oct 20, 2010 10:25 pm
Hi,
I am trying to use abovecommand on mercury flight application.
Below is command i am using :
col = sel.get_xpath_count("//table[1]/tbody/tr[7]/td")
it is returning 6
and for rows
row = sel.get_xpath_count("//table[1]/tbody/tr")
it is returning 36
But actually there are only 5 columns and 10 rows in table.
Can you please help me out of this?
I am trying to use abovecommand on mercury flight application.
Below is command i am using :
col = sel.get_xpath_count("//table[1]/tbody/tr[7]/td")
it is returning 6
and for rows
row = sel.get_xpath_count("//table[1]/tbody/tr")
it is returning 36
But actually there are only 5 columns and 10 rows in table.
Can you please help me out of this?
- PriyankaRegular Participant
- Posts : 27
Join date : 2010-10-04
Re: how to store number of rows of a table
Thu Dec 02, 2010 3:52 pm
how to get the total no of rows from a table using selenium?
Am using c#.
From the view source am getting only table's class. Table id is not getting. Can anyone pls help
Am using c#.
From the view source am getting only table's class. Table id is not getting. Can anyone pls help
Permissions in this forum:
You cannot reply to topics in this forum