Skip to content

Commit

Permalink
Merge pull request #89 from Omenia/listview-keywords
Browse files Browse the repository at this point in the history
New keywords for handling text in listview
  • Loading branch information
eeromakiesko authored Feb 7, 2019
2 parents 2664139 + 5565b5a commit 7be8ace
Show file tree
Hide file tree
Showing 10 changed files with 401 additions and 129 deletions.
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
29 changes: 6 additions & 23 deletions atests/feature_tests/items.robot
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
*** Variables ***
${TEST APPLICATION} ${EXECDIR}${/}UIAutomationTest${/}bin${/}Debug${/}UIAutomationTest.exe
${TEST APPLICATION} ${EXECDIR}/UIAutomationTest/bin/Debug/UIAutomationTest.exe
${ARGUMENTS} "generic_argument"
@{Tree node 1} Tree node 1
@{Tree node 1.1} Tree node 1 Tree node 1.1


*** Settings ***
Library OperatingSystem
Library String
Library WhiteLibrary
Test Setup Attach Main Window
Test Teardown Clean Application
Resource ..${/}resource.robot
Resource ../resource.robot

*** Test Cases ***
Verify Labels
Expand Down Expand Up @@ -86,17 +85,16 @@ Calculate When First Number is Missing
Calculate When First Number Is Alphabet
Calculate a + 5 Equals ${EMPTY}


Verify Radio Buttons
Verify Radio Button rb_peke ${TRUE}
Select Radio Button rb_ismo
Verify Radio Button rb_ismo ${TRUE}

Verify Get Radio Button State
${old_button_state}= Get Radio Button State rb_ismo
${old_button_state}= Get Radio Button State rb_ismo
Select Radio Button rb_ismo
${new_button_state}= Get Radio Button State rb_ismo
Should Not Be Equal ${old_button_state} ${new_button_state}
${new_button_state}= Get Radio Button State rb_ismo
Should Not Be Equal ${old_button_state} ${new_button_state}

Verify Slider
Verify Slider Value sladdu 0
Expand Down Expand Up @@ -209,22 +207,7 @@ Handle ToolStripButtons
Toolstrip button 3 Should Be Clicked
[Teardown] Select Tab Page tabControl Tab1

Handle ListView
[Setup] Setup for Tab 2 Tests
Select ListView Row By Index list_view 1
Bible Should Be Selected
Select ListView Row By Index list_view 2
The Art of Computer Programming Should Be Selected
Select ListView Row list_view Title Robinson Crusoe
Robinson Crusoe Should Be Selected

Repeat Keyword 2 Right Click Listview Cell list_view2 Title 1
Bible Should Be Right Clicked
Repeat Keyword 2 Right Click Listview Cell list_view2 Author 0
Daniel Defoe Should Be Right Clicked
[Teardown] Select Tab Page tabControl Tab1

ListView Row Right Click Menu
Popup menu with subitems
[Setup] Setup for Tab 2 Tests
Right Click ListView Row By Index list_view 2
Click Item In Popup Menu Delete
Expand Down
87 changes: 87 additions & 0 deletions atests/feature_tests/listview.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
*** 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 P
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

ListView Select
Select ListView Row By Index list_view 1
Bible Should Be Selected
Select ListView Row By Index list_view 2
The Art of Computer Programming Should Be Selected
Select ListView Row list_view Title Robinson Crusoe
Robinson Crusoe Should Be Selected

ListView Right Click
Repeat Keyword 2 Right Click Listview Cell list_view2 Title 1
Bible Should Be Right Clicked
Repeat Keyword 2 Right Click Listview Cell list_view2 Author 0
Daniel Defoe Should Be Right Clicked
5 changes: 4 additions & 1 deletion atests/resource.robot
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
*** Settings ***
Library String
Library WhiteLibrary

*** Variables ***
${TEST APPLICATION} ${EXECDIR}${/}UIAutomationTest${/}bin${/}Debug${/}UIAutomationTest.exe
${TEST APPLICATION NAME} UIAutomationTest
Expand All @@ -24,7 +28,6 @@ Launch White Application For Test
Attach White Main Window
Attach Window ${TEST WHITE APPLICATION NAME}


Clean Application
Input Text To Textbox txtA ${EMPTY}
Input Text To Textbox txtB ${EMPTY}
Expand Down
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

0 comments on commit 7be8ace

Please sign in to comment.