angularjs e2e - Protractor and xpath to navigate the DOM -


i'm able use csscontainingtext() grid row, , fetch id attribute follows:

this.getrowidbytext = function (text) {    var sel = '#thereport .ui-grid-viewport .ui-grid-canvas';   var firstrow = element.all(by.css(sel)).first();   var gridrows = firstrow.all(by.repeater('(rowrenderindex, row) in rowcontainer.renderedrows track $index'));    var result = gridrows.all(by.csscontainingtext('div', "col 1, row 1 text contents")).first();    var parentid = result.all(by.xpath("./div")); // "./ancestor::div[starts-with(@id, 'id')]" return parentid.getattribute("id"); 

but i'd use xpath expression fetch related data row, text value "my value - col2, row 1" , id="1484316102519-0-uigrid-0007-cell".

here sample dom -

<div class="ui-grid-contents-wrapper">     <div class="grid-menu-stuff">...</div>       <!-- left-most columns -->     <div class="grid-container-left">     	<div class="grid-header">...</div>     	<div role="rowgroup" class="ui-grid-viewport">     	        	   <div class="ui-grid-canvas">     	   	<!-- here row repeater !!! -->     	   	<div ng-repeat="row in rowcontainer.renderedrows">     	   	   <div ui-grid-row="row">     	   	      <div class="ui-grid-cell">     	   	           	   	        <!-- col 1, row 1 -->     	   	         <div id="1484316102519-0-uigrid-0006-cell">     	   	            <div class="ui-grid-cell-contents" title="col 1, row 1 text contents"> col 1, row 1 text contents</div>     	   	         </div>     	   	              	   	      </div>     	   	   </div>        	   	</div>	     	   	<div ng-repeat="row in rowcontainer.renderedrows">     	   	   <div ui-grid-row="row">  		      <div class="ui-grid-cell">  		        		         <!-- col 1, row 2 -->  			 <div id="1484316102519-1-uigrid-0006-cell">  			    <div class="ui-grid-cell-contents" title="col 1, row 2 text contents"> col 1, row 2 text contents</div>  			 </div>  		      </div>     	   	   </div>    		   	   	  		   	   	     	   	</div>     	   	<div ng-repeat="row in rowcontainer.renderedrows">  		   	   	     	   	</div>     	   </div>        	        	</div>     </div>          <!-- data rows -->     <div role="rowgroup" class="ui-grid-viewport">        <div class="ui-grid-canvas">           <div ng-repeat="row in rowcontainer.renderedrows">              <div ui-grid-row="row">                 <div ui-grid-row="row">                    <div ng-repeat="col in columns" id="1484316102519-0-uigrid-0007-cell">                            <div class="ui-grid-cell-contents" title="my value - col2, row 1">my value - col2, row 1</div>                    </div>                 </div>              </div>           </div>                      <div ng-repeat="row in rowcontainer.renderedrows">  	     <div ui-grid-row="row">  		<div ui-grid-row="row">  		   <div ng-repeat="col in columns" id="1484316102519-1-uigrid-0007-cell">       		      <div class="ui-grid-cell-contents" title="my value - col2, row 2">my value - col2, row 2</div>  		   </div>  		</div>  	     </div>           </div>                   </div     </div>  </div>

i noticed there correlation generation of div id's, strip id down , infer related data cell; however, there way use xpath related div ?

perhaps i'm looking sibling element, i'm not clear how accomplish using xpath expressions.

thanks, bob

my solution specific ui-grid, perhaps in future. considering snippet dom sample above, note -1- represents row number, -0006 col number:

 <!-- col 1, row 2 -->  <div id="1484316102519-1-uigrid-0006-cell">     <div class="ui-grid-cell-contents" title="col 1, row 2 text contents"> col 1, row 2 text contents</div>  </div> 

i can't first rows repeater:

var rows mygrid.all(by.repeater('...'));

then row text:

var result = rows.all(by.csscontainingtext('div', 'col 1, row 2 text contents')).first();

in case, needed first parent div in order grab id attrib:

var parid = result.all(by.xpath("./div")); var myrowid parid.getattribute)"id");

now having row id need, i'll extract row number can data rows of ui-grid:

var rowid = myrowid.split('-')[1];

now can data row :

var row = this.getdatarows().get(rowid); // getdatarows internal function lib.

once have row, i'm go.

i hope helps in future.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -