MuraliKola / robotframework-seleniumlibrary

Automatically exported from code.google.com/p/robotframework-seleniumlibrary
Apache License 2.0
1 stars 0 forks source link

Keywords for checking and getting table content #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Get Table Cell Value
Table Cell Value Should Be
Get Table Row
Get Table Column

and possibly some others should be implmented

Original issue reported on code.google.com by janne.t....@gmail.com on 5 Feb 2009 at 8:41

GoogleCodeExporter commented 8 years ago
Row and Column count would also be nice.
I want to click on a link in a table (result of a previous search action) based 
on a
value in different column in same row.
I need keywords to support this.

Original comment by mauricek...@gmail.com on 1 Feb 2010 at 10:18

GoogleCodeExporter commented 8 years ago
I believe it should be possible to achieve most with some clever css selectors 
and
nth-of-type pseudo elements (and use "Element should contain" keyword 
internally). 

Table Should Contain         some text
Table Header Should Contain  some text
Table Row Should Contain     2  some text
Table Column Should Contain  4  some text
Table Cell Should Contain    2  4  some text

Row and Column count would be difficult, but I assume you want to know the 
numbers to
assert on them. You could also do that with one of the keywords above:

Table Row Should Contain    14  some text

This would assert that the table has at least 14 rows. It would even be 
possible to
use special "first" or "last" instead of concrete row/column count to assert for
first or last row/column.

I'll try this out :)

Original comment by Andreas.EbbertKarroum@gmail.com on 24 Apr 2010 at 11:27

GoogleCodeExporter commented 8 years ago
The proposed keywords look great! Few issues to decide still:

1) How should `Table Cell Should Contain` behave? Should it verify that the 
given
text exists in the cell or that the text matches the cell contents exactly? In 
the
latter case it should probably be named `Table Cell Content Should Be`. I think
`Contains` is better.

2) Should we also implement `Get Table Cell` (or `Get Table Cell Content`)? It 
would
be useful because then it's possible to use BuiltIn keywords such as `Should 
Match
Regexp` to create user keywords with more complicated checks.

3) Keywords that return more cells (`Get Table Cells`, `Get Table Row`) would 
be nice
too but may be complicated to implement. These keywords should return lists 
that can
be then checked/manipulated with Collection library keywords. If these are 
hard, they
can be implemented later.

4) Should row/column indexes start from 0 or 1? In this usage I'd prefer 1.

5) Special indexes `first` and `last` are a good idea. It would probably be a 
good
idea to support also negative indexes that start from the end. For example -1 
would
be the last index, -2 the second last, and so on.

Original comment by pekka.klarck on 25 Apr 2010 at 5:30

GoogleCodeExporter commented 8 years ago
Issue 104 has been merged into this issue.

Original comment by pekka.klarck on 25 Apr 2010 at 5:40

GoogleCodeExporter commented 8 years ago
1) I agree. -> "Contains"
2/3) When retrieving content, you get into the business of parsing the html 
document.
It can be done (after all, we can get the sources of the page), but I don't 
know the
proper python libs to do that
4) don't know. do we have other indexes in selenium, SeleniumLibrary or RF? do 
they
start normally on 1 or 0? If we can choose, starting from 1 seems reasonable.
5) good idea, should be working with css pseudo-class :nth-last-of-type()

Many of these css selectors are css3 and only supported by newer browsers. I 
will put
in the docs a link to a compatibility chart. Also the table should be 
identifyable by
id or name. 

Original comment by Andreas.EbbertKarroum@gmail.com on 25 Apr 2010 at 8:06

GoogleCodeExporter commented 8 years ago
2) just stumbled over a nice selenium function "get_table" :) I still think 
that we
should start indexes from 1 and convert that before calling selenium.

http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/python/sele
nium.selenium-class.html#get_table

3) leave it for later :)

Original comment by Andreas.EbbertKarroum@gmail.com on 25 Apr 2010 at 9:11

GoogleCodeExporter commented 8 years ago
Looks good. I agree 3) can be left for later if it's not easy to implement.

Original comment by pekka.klarck on 25 Apr 2010 at 9:39

GoogleCodeExporter commented 8 years ago
initial work in revision 96018b7b28

Original comment by Andreas.EbbertKarroum@gmail.com on 25 Apr 2010 at 10:02

GoogleCodeExporter commented 8 years ago
Nice work so far!
'Get Table Cell' is something I really need.

NOTE: Any ideas how to handle nested tables?

Original comment by mauricek...@gmail.com on 26 Apr 2010 at 5:59

GoogleCodeExporter commented 8 years ago
Thanks :)

How do you want to have nested tables handled? IMHO it's a table like any other
table. Means if you say that the outer table should contain any text in a row, 
column
or cell, that contains a nested table, when the nested table contains that 
text, it
matches.
Also, a nested table can be identified by id, so you can just make assertions 
for the
nested table on it's own.

Yesterday I ran into the problem, that with css selectors, your cannot match by 
id OR
by name, just one or the other (at least to the best of my knowledge). We could 
make
seperate assertions to and let the keyword only fail, if neither of them 
matches. or
we say, we only check by id, and if the users want's something more 
sophisticated, he
can still build the css selector on his own. Thoughts?

Original comment by Andreas.EbbertKarroum@gmail.com on 26 Apr 2010 at 9:33

GoogleCodeExporter commented 8 years ago
This is the current set of tables, that I intent to use for testing, anything 
that is
missing in your opinion?

http://robotframework-seleniumlibrary.googlecode.com/hg/test/resources/html/tabl
es/tables.html?r=96018b7b28bc021470f7930d5f697fef66312794

Original comment by Andreas.EbbertKarroum@gmail.com on 26 Apr 2010 at 9:35

GoogleCodeExporter commented 8 years ago
Selenium's get_table command only works with IDs, not with name attributes, so I
would make the new table keywords work with IDs as well. (If we discover, that 
we
need to match on names optionally, we can hopefully add it later).

Maurice, would that be ok with you?

How do you intent to work with the "Get Table Cell" keyword? 

Original comment by Andreas.EbbertKarroum@gmail.com on 26 Apr 2010 at 9:41

GoogleCodeExporter commented 8 years ago
I think support for IDs is enough at least initially. That's the attribute you
should, AFAIK, use in this kind of situations anyway. Is it still possible to 
support
for free xpath expressions?

All this needs to be obviously documented adequately. 

Original comment by pekka.klarck on 26 Apr 2010 at 9:51

GoogleCodeExporter commented 8 years ago
xpath probably not, but I could imagine, that we can pass in a css selector 
which we
then extend. 

Original comment by Andreas.EbbertKarroum@gmail.com on 26 Apr 2010 at 10:39

GoogleCodeExporter commented 8 years ago
Andreas committed most of these keywords in revision d52872e30d. Great work!

Original comment by pekka.klarck on 29 Apr 2010 at 9:26

GoogleCodeExporter commented 8 years ago
This issue was updated by revision 814f368abb.

Comment: tables can now be identified with a css locator

Original comment by Andreas.EbbertKarroum@gmail.com on 30 Apr 2010 at 12:13

GoogleCodeExporter commented 8 years ago
This issue was updated by revision d2a9e38611.

Comment: Implemented Pekka's review comments from 
http://code.google.com/p/robotframework-seleniumlibrary/source/detail?r=d52872e3
0d

Original comment by Andreas.EbbertKarroum@gmail.com on 30 Apr 2010 at 12:13

GoogleCodeExporter commented 8 years ago
This issue was updated by revision 942083c4b0.

Comment: keyword documentation

Original comment by Andreas.EbbertKarroum@gmail.com on 30 Apr 2010 at 12:57

GoogleCodeExporter commented 8 years ago
Hi,

I added the documentation of the keywords. Could you please take a look at all 
the
table related keywords and let me know, if you miss something?

http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html

Thanks!
Andreas

Original comment by Andreas.EbbertKarroum@gmail.com on 30 Apr 2010 at 12:57

GoogleCodeExporter commented 8 years ago
This issue was updated by revision cc1a942932.

Comment: Ooops, forgot to commit the python keyword docs.

Original comment by Andreas.EbbertKarroum@gmail.com on 30 Apr 2010 at 4:03

GoogleCodeExporter commented 8 years ago
If there are no further comments, I consider this issue completed :)

Original comment by Andreas.EbbertKarroum@gmail.com on 2 May 2010 at 9:03

GoogleCodeExporter commented 8 years ago
Docs look good already. See my comments to revision cc1a942932, though.

Original comment by pekka.klarck on 3 May 2010 at 4:33

GoogleCodeExporter commented 8 years ago
This issue was updated by revision 47c1c0d25f.

Comment: incorporated Pekka's comments regarding the documentation. I wonder if 
we also should have keywords for negative tests (Table Must Not Contain"). They 
would be useful, but also bloat the library a little bit.

Original comment by Andreas.EbbertKarroum@gmail.com on 3 May 2010 at 9:48

GoogleCodeExporter commented 8 years ago
Keywords that are useful should obviously be added. If it's not sure are they 
really
needed, they can be added later when the need arises. I'd say the current 
keywords
enough for this release.

From the Zen of Python:

    Now is better than never.
    Although never is often better than *right* now.

Original comment by pekka.klarck on 3 May 2010 at 10:35

GoogleCodeExporter commented 8 years ago
I agree. Let's go public with this and see if we need more.

Original comment by Andreas.EbbertKarroum@gmail.com on 8 May 2010 at 11:43

GoogleCodeExporter commented 8 years ago
Major improvements warrant a major version

Original comment by janne.t....@gmail.com on 27 May 2010 at 9:39

GoogleCodeExporter commented 8 years ago
Hi,

Do you know in near future if 'Table Row Should Not Contain' would work? You 
got any suggestions how to get the same functionality?

Original comment by efsungur...@gmail.com on 8 Jun 2012 at 8:00