php - Click a button with XPath using an id from the same row -


im testing using phpunit , need create , delete same things. create called test, want able find , delete it. have multiple delete buttons on page, , works doing -

    $this->click("xpath=(//img[@title='delete'])[11]");

but choosing [11] example, using delete button row 11. , if test isnt row 11 example, delete not wish delete.

i wish try , delete specific row finding row id attached it.

the row may have words "test" followed more information within columns. delete button @ end titled 'delete'. wish find row id or words 'test' , find , use 'delete' title on row.

any help?

edit -example image of row. grab first text, , use last button on right titled 'delete'

http://i.stack.imgur.com/s4bne.png

second edit - whole table, contains of rows , within rows contains td's (obviously, you'd know). ill find text im trying find. tr count 4th of 6.

this shows td containing delete, td containing 'test profile' , whole table itself. http://i.imgur.com/4r1tsje.png

tl;dr essentially, im trying do, td contains 'test', use 'delete' same row.

not clear i'll try guess comments.

forget rows, let's find td "test" (or text want in it)

descendant::td[contains(.,'test')]/ 

and here select following-sibling td contains delete image

following-sibling::td//img[@title='delete'] 

now have set of images nodes click on, each row.

of course, if function

$this->click("xpath=....."); 

accepts 1 node @ time, 1 possibility put parenthesis , select first node (assuming test delete it)

(descendant::td[contains(.,'test')]/following-sibling::td//img[@title='delete'])[1] 

even if node deleted when click on it, in next test expression match, until there node left on page

this similar (not same) having loop ?

buttons = "xpath=....."  each b in buttons {  $this->click(b); } 

hope helps


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -