@@ -172,6 +172,32 @@ def _table_path_convert(path):
172172 tp = table_path , rt = row_type , r = row , ct = column_type , c = column , cp = cell_path )
173173
174174
175+ def _list_path_convert (path ):
176+ # Contract
177+ must_be (path , "path" , basestring )
178+ #
179+ parts = path .split ('\\ ' )
180+ if len (parts ) < 2 :
181+ raise ValueError ("path value must be: list_path\\ [item_type:]item[\\ item_path]" )
182+
183+ list_path = parts .pop ()
184+
185+ item = parts .pop ()
186+ item_type = "li"
187+ data = item .split (":" )
188+ if len (data ) == 1 :
189+ item = int (item )
190+ else :
191+ item_type = data [0 ]
192+ item = int (data [1 ])
193+
194+ item_path = ""
195+ if len (parts ) >= 1 :
196+ item_path = "/" + parts .pop ()
197+
198+ return '{lp}/{it}[{i}]{ip}' .format (lp = list_path , it = item_type , i = item , ip = item_path )
199+
200+
175201# Implement the class, add existing values
176202By = ByDict ()
177203# Is this the best way to do this? Allow retrieving key: None = value: None (for simplifying step parsing)
@@ -182,6 +208,7 @@ def _table_path_convert(path):
182208
183209By .INNER_TEXT = ByClause (selenium_by .XPATH , _inner_text_convert )
184210By .TABLE_PATH = ByClause (selenium_by .XPATH , _table_path_convert )
211+ By .LIST_PATH = ByClause (selenium_by .XPATH , _list_path_convert )
185212By .NG_CLICK = ByClause (selenium_by .CSS_SELECTOR , lambda v : '[ng-click="{}"]' .format (v ))
186213By .VISIBLE_CLICK = ByClause (selenium_by .CSS_SELECTOR , lambda v : '[ng-click="{}"]:not(.ng-hide)' .format (v ))
187214By .NG_MODEL = ByClause (selenium_by .CSS_SELECTOR , lambda v : '[ng-model="{}"]' .format (v ))
0 commit comments