Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New keywords for handling text in listview #89

Merged
merged 12 commits into from
Feb 7, 2019
1 change: 0 additions & 1 deletion UIAutomationTest/UIAutomationTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="oldcalcwin10.zip" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings" />
</ItemGroup>
Expand Down
78 changes: 78 additions & 0 deletions atests/feature_tests/listview.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
*** Settings ***
Library WhiteLibrary
Resource ../resource.robot
Suite Setup Setup for Tab 2 Tests
Suite Teardown Select Tab Page tabControl Tab1

*** Test Cases ***
Row Verification
Listview Row Should Contain list_view2 Title Bible ligious
Listview Row Should Not Contain list_view2 Title Robinson Crusoe Scienc
Listview Row In Index Should Contain list_view2 2 Programming
Listview Row In Index Should Not Contain list_view2 1 Donald

Cell Verification
Listview Cell Text Should Be list_view2 Title 2 The Art of Computer Programming
Listview Cell Text Should Not Be list_view2 Title 2 Robinson Crusoe
Listview Cell Text In Index Should Be list_view2 2 1 The Art of Computer Programming
Listview Cell Text In Index Should Not Be list_view2 2 1 Robinson Crusoe

Listview Cell Should Contain list_view2 Title 2 omputer
Listview Cell Should Not Contain list_view2 Title 2 obinson
Listview Cell In Index Should Contain list_view2 2 1 omputer
Listview Cell In Index Should Not Contain list_view2 2 1 obinson

Unsuccessful Row Verification
Run Keyword And Expect Error Row defined by cell 'Title'='Bible' did not contain text 'abcd'
... Listview Row Should Contain list_view2 Title Bible abcd
Run Keyword And Expect Error Row defined by cell 'Title'='Robinson Crusoe' should not have contained text 'Fiction'
... Listview Row Should Not Contain list_view2 Title Robinson Crusoe Fiction
Run Keyword And Expect Error Row 2 did not contain text 'abcd'
... Listview Row In Index Should Contain list_view2 2 abcd
Run Keyword And Expect Error Row 1 should not have contained text 'igious'
... Listview Row In Index Should Not Contain list_view2 1 igious

Unsuccessful Cell Verification
Run Keyword And Expect Error Cell text should have been 'Hello', found 'The Art of Computer Programming'
... Listview Cell Text Should Be list_view2 Title 2 Hello

Run Keyword And Expect Error Cell text should not have been 'The Art of Computer Programming'
... Listview Cell Text Should Not Be list_view2 Title 2 The Art of Computer Programming

Run Keyword And Expect Error Cell (2, 1) text should have been 'Hello', found 'The Art of Computer Programming'
... Listview Cell Text In Index Should Be list_view2 2 1 Hello

Run Keyword And Expect Error Cell (2, 1) text should not have been 'The Art of Computer Programming'
... Listview Cell Text In Index Should Not Be list_view2 2 1 The Art of Computer Programming

Run Keyword And Expect Error Cell did not contain text 'obinson'
... Listview Cell Should Contain list_view2 Title 2 obinson

Run Keyword And Expect Error Cell should not have contained text 'omputer'
... Listview Cell Should Not Contain list_view2 Title 2 omputer

Run Keyword And Expect Error Cell (2, 1) did not contain text 'obinson'
... Listview Cell In Index Should Contain list_view2 2 1 obinson

Run Keyword And Expect Error Cell (2, 1) should not have contained text 'omputer'
... Listview Cell In Index Should Not Contain list_view2 2 1 omputer

Get Text From ListView
${expected} Create List Donald Knuth The Art of Computer Programming Science
${actual} Get Listview Row Text list_view2 Category Science
Should Be Equal ${actual} ${expected}

${expected} Create List Daniel Defoe Robinson Crusoe Fiction
${actual} Get Listview Row Text By Index list_view2 0
Should Be Equal ${actual} ${expected}

${actual} Get Listview Cell Text list_view2 Author 0
Should Be Equal ${actual} Daniel Defoe

${actual} Get Listview Cell Text By Index list_view2 2 2
Should Be Equal ${actual} Science

*** Keywords ***
Setup For Tab 2 Tests
Attach Main Window
Select Tab Page tabControl Tab2
2 changes: 2 additions & 0 deletions src/WhiteLibrary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from WhiteLibrary.keywords.items import (ButtonKeywords,
LabelKeywords,
ListKeywords,
ListViewKeywords,
MenuKeywords,
MouseKeywords,
ProgressbarKeywords,
Expand Down Expand Up @@ -115,6 +116,7 @@ def __init__(self):
KeyboardKeywords(self),
LabelKeywords(self),
ListKeywords(self),
ListViewKeywords(self),
MenuKeywords(self),
MouseKeywords(self),
ProgressbarKeywords(self),
Expand Down
1 change: 1 addition & 0 deletions src/WhiteLibrary/keywords/items/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .buttons import ButtonKeywords # noqa: F401
from .label import LabelKeywords # noqa: F401
from .listcontrols import ListKeywords # noqa: F401
from .listview import ListViewKeywords # noqa: F401
from .menu import MenuKeywords # noqa: F401
from .mouse import MouseKeywords # noqa: F401
from .progressbar import ProgressbarKeywords # noqa: F401
Expand Down
73 changes: 0 additions & 73 deletions src/WhiteLibrary/keywords/items/listcontrols.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from TestStack.White.UIItems.ListBoxItems import ComboBox, ListBox
from TestStack.White.UIItems import ListView
from WhiteLibrary.keywords.librarycomponent import LibraryComponent
from WhiteLibrary.keywords.robotlibcore import keyword
from robot.api import logger
Expand Down Expand Up @@ -87,75 +86,3 @@ def verify_combobox_selection(self, locator, expected):
"""
combobox = self.state._get_typed_item_by_locator(ComboBox, locator)
self.state._verify_value(expected, combobox.EditableText)

@keyword
def select_listview_row(self, locator, column_name, cell_text):
"""Selects a listview row that has given text in given column.

``locator`` is the locator of the listview.

``column_name`` is the name of the column.

``cell_text`` is the text that should be in the cell defined by the given column.

Example:
| Select Listview Row | id:addressList | City | Helsinki | # select row that has value "Helsinki" in the column "City" |
"""
listview = self.state._get_typed_item_by_locator(ListView, locator)
listview.Select(column_name, cell_text)

@keyword
def select_listview_row_by_index(self, locator, row_index):
"""Selects a listview row by its index.

``locator`` is the locator of the listview.

``row_index`` is the zero-based index to select.
"""
listview = self.state._get_typed_item_by_locator(ListView, locator)
listview.Select(int(row_index))

@keyword
def right_click_listview_row(self, locator, column_name, cell_text):
"""Right clicks a listview row that has given text in given column.

``locator`` is the locator of the listview.

``column_name`` is the name of the column.

``cell_text`` is the text that should be in the cell defined by the given column.

See example in `Select Listview Row` on how to use the arguments.
"""
listview = self.state._get_typed_item_by_locator(ListView, locator)
row = listview.Rows.Get(column_name, cell_text)
row.RightClick()

@keyword
def right_click_listview_row_by_index(self, locator, row_index):
"""Right clicks a listview row by its index.

``locator`` is the locator of the listview.

``row_index`` is the zero-based row index.
"""
listview = self.state._get_typed_item_by_locator(ListView, locator)
row = listview.Rows.Get(int(row_index))
row.RightClick()

@keyword
def right_click_listview_cell(self, locator, column_name, row_index):
"""Right clicks a listview cell using its column name and row index.

``locator`` is the locator of the listview.

``column_name`` is the name of the column.

``row_index`` is the zero-based row index.

Example:
| Right Click Listview Cell | id:userList | Name | 0 |
"""
listview = self.state._get_typed_item_by_locator(ListView, locator)
cell = listview.Cell(column_name, int(row_index))
cell.RightClick()
Loading