0

I'm trying to delete click on link generated by a previous test (a delete link) but I'm having great difficulty with xpath

Here is the error I am receiving

Invalid response while accessing the Selenium Server at 'http://localhost:4444/s
elenium-server/driver/': ERROR: Element xpath=(//td[normalize-space() ='Test tit
le 2']/following-sibling::td[3]/descendant::a[.='delete']) not found

here is my test

public function testdeleteStationTestCase()
    {
        $this->open("/upd8r_new/");
        $this->click("css=a > img");
        $this->waitForPageToLoad("30000");
        $this->type("name=username", "glass2");
        $this->type("name=password", "glass2");
        $this->click("name=submit");
        sleep(1);
        $this->click("xpath=(//td[normalize-space() ='Test title 2']/following-sibling::td[3]/a[.='delete'])");
        //$this->click("xpath=(//td[normalize-space() ='Test title 2']/following-sibling::td[3]/descendant::a[.='delete'][1])");

        sleep(1);


        $this->assertTrue($this->isTextPresent("Station deleted!"),"Station Deleted");
    }

as you can see my commented out line i have been trying all sorts of combinations to get the test to run-

here is the html page I am testing against- i have added a line of text where I am trying to click

<body>
<!-- social media header -->
<div class="main">
    <div class="header">
        Central Control Panel

    </div>

    <div class="logo">
                    <img src="http://localhost/upd8r_new/imgs/loyalty_connect2.png"/>
            </div>

    <div style="clear:both"></div>



    <ul class="Menu" id="maintab">
        <li class="selected" rel="home"><a href="http://localhost/upd8r_new/socialmedia">HOME</a>       </li>

        <li  rel="retail">
            <a href="http://localhost/upd8r_new/social_retail">RETAIL</a>       </li>




        <li   rel="stats"> <a href="http://localhost/upd8r_new/socialmedia/stats">STATS</a></li>
        <li 






            rel="social_media_settings"> <a href="http://localhost/upd8r_new/socialmedia/settings">SETTINGS</a></li>
        <li rel="logout"><a href="http://localhost/upd8r_new/login/logout">LOGOUT</a> </li>
    </ul>   


    <div style="clear:both"></div>
    <div style="text-align:left;width:980px;height:40px;background-color:#0E477A;margin:auto;padding-top:0px;">

        <div style="width:700px;text-align:left;padding-left:10px;float:left">

            <div id="logout" class="submenustyle">

            </div>
                        <div id="retail" class="submenustyle">
                <ul class="sub_menu">
                    <li><a href="http://localhost/upd8r_new/social_retail">USERS</a></li>
                    <li><a href="http://localhost/upd8r_new/social_retail/view_competitions">COMPETITIONS</a></li>

                </ul>               
            </div>
                        <div id="home" class="submenustyle">
                <ul class="sub_menu">
                    <li><a href="http://localhost/upd8r_new/socialmedia/add">ADD LIKESTATION</a></li>
                    <li><a href="http://localhost/upd8r_new/socialmedia/add_picstation">ADD PICSTATION</a></li>
                    <li><a href="http://localhost/upd8r_new/socialmedia/add_vidstation">ADD VIDSTATION</a></li>
                </ul>

            </div>
            <div id="socialmedia_users" class="submenustyle">

            </div>
            <div id="stats" class="submenustyle">
                <ul class="sub_menu">
                    <li><a href="http://localhost/upd8r_new/socialmedia/stats">STATS HOME</a></li>
                    <li><a href="http://localhost/upd8r_new/socialmedia/stats/facebook/stats">FACEBOOK STATS</a></li>


                </ul>
            </div>


            <div id="social_media_settings" class="submenustyle">
                <ul class="sub_menu">
                    <li><a href="http://localhost/upd8r_new/socialmedia/settings">SETTINGS HOME</a></li>
                    <li><a href="http://localhost/upd8r_new/socialmedia/registration_settings">NETWORKS TO USE</a></li>

                    <li><a href="http://localhost/upd8r_new/socialmedia/pre_settings">PRE REGISTRATION</a></li>
                                            <li>
                        <a href="http://localhost/upd8r_new/socialmedia/app_settings">APP SETTINGS</a>                  
                        </li>
                                    </ul>
            </div>


        </div>
        <div style="float:right;font-weight:bold;color:#fff;margin-top:12px;margin-right: 20px;">
                        Logged In As: glass2        </div>

    </div>
    <div style="clear:both"></div>


    <div style="padding-top:30px;padding-left:10px">Station deleted! </div>
    <div style="padding-left:10px">



                        <table width="700px" align="left" style="text-align:left;">
            <tr>
                <td style="font-weight:bold">Pre-Registration</td>
                <td><a href="http://localhost/upd8r_new/retail/register/80">http://localhost/upd8r_new/retail/register/80</a></td>
            </tr>

        </table>
                <div style="clear:both"></div>

        <table width="800px" align="left" style="text-align:left;">
            <tr style="font-weight:bold;background-color:#f1f1f1">
                <td colspan="6" STYLE="text-align:center;font-weight:bold">LIKESTATIONS</td>
            </tr>
            <tr style="font-weight:bold;background-color:#f1f1f1">
                <td width="10%">STATION ID</td>
                <td width="32%">STATION NAME</td>
                <td width="25%">LINK TITLE</td>
                <td width="10%">STATION STATS</td>
                <td width="15%">LAST POST</td>
                <td width="8%"></td>

            </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit/gla20311344">gla20311344</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit/gla20311344">http://localhost/upd8r_new/socialmedia/edit/gla20311344</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit/gla20311344">Webcast</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla20311344">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla20311344">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit/gla2084629867">gla2084629867</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit/gla2084629867">http://localhost/upd8r_new/socialmedia/edit/gla2084629867</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit/gla2084629867">tes this link title3</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla2084629867">STATS</a> </td>
                    <td>4 weeks ago</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla2084629867">delete</a></td>
                </tr>
                    </table>

        <div style="clear:both"></div>

        <table width="620px" align="left" style="text-align:left;">
            <tr style="font-weight:bold;background-color:#f1f1f1">
                <td colspan="5" STYLE="text-align:center;font-weight:bold">FACEBOOK PIC STATIONS</td>
            </tr>
            <tr style="font-weight:bold;background-color:#f1f1f1">
                <td width="15%">STATION ID</td>
                <td width="50%">STATION TITLE</td>
                <td width="10%">STATION STATS</td>
                <td width="15%">LAST POST</td>
                <td width="10%"></td>

            </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1079978359">gla1079978359</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1079978359">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla1079978359">STATS</a> </td>
                    <td>0</td>
                    <td>**link I'm trying to click**<a href="http://localhost/upd8r_new/socialmedia/delete/gla1079978359">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1229158969">gla1229158969</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1229158969">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla1229158969">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla1229158969">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1256364596">gla1256364596</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1256364596">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla1256364596">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla1256364596">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1529784490">gla1529784490</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1529784490">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla1529784490">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla1529784490">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla159062284">gla159062284</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla159062284">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla159062284">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla159062284">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla175038477">gla175038477</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla175038477">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla175038477">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla175038477">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1777127061">gla1777127061</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1777127061">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla1777127061">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla1777127061">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla180142977">gla180142977</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla180142977">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla180142977">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla180142977">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1950664292">gla1950664292</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1950664292">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla1950664292">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla1950664292">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1971709701">gla1971709701</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla1971709701">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla1971709701">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla1971709701">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2028774169">gla2028774169</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2028774169">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla2028774169">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla2028774169">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2035285297">gla2035285297</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2035285297">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla2035285297">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla2035285297">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2072665757">gla2072665757</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2072665757">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla2072665757">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla2072665757">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2115042517">gla2115042517</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2115042517">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla2115042517">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla2115042517">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2141659529">gla2141659529</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla2141659529">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla2141659529">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla2141659529">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla4705592">gla4705592</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla4705592">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla4705592">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla4705592">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla565900575">gla565900575</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla565900575">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla565900575">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla565900575">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla608150382">gla608150382</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla608150382">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla608150382">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla608150382">delete</a></td>
                </tr>
                            <tr>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla979271929">gla979271929</a> </td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/edit_picstation/gla979271929">Test title 2</a> </td>
                    <td><a href="http://localhost/upd8r_new/stats/home/station_stats/gla979271929">STATS</a> </td>
                    <td>0</td>
                    <td><a href="http://localhost/upd8r_new/socialmedia/delete/gla979271929">delete</a></td>
                </tr>
                    </table>

        <div style="clear:both"></div>

        <table width="520px" align="left" style="text-align:left;">
            <tr style="font-weight:bold;background-color:#f1f1f1">
                <td colspan="4" STYLE="text-align:center;font-weight:bold">FACEBOOK VIDEO STATIONS</td>
            </tr>
            <tr style="font-weight:bold;background-color:#f1f1f1">
                <td width="20%">STATION ID</td>
                <td width="60%">STATION TITLE</td>
                <td width="60%">STATION STATS</td>
                <td width="20%"></td>
            </tr>
                    </table>


        <div style="clear:both"></div>


</div>
</div>
<div class="footer">
    <div style="float:left;padding-top:20px;padding-left:20px;font-size:10px;font-family:arial"></div>
    <div style="padding-top:20px;float:right;padding-right:30px;"><img src="http://localhost/upd8r_new/imgs/excelerated.jpg"/></div>
</div>
</body>
</html>
1
  • commented line is not equal to what I suggested in my previous answer :) And all these brackets are useless as selenium select only first occurrence by default Commented May 2, 2012 at 10:56

2 Answers 2

1

Your problem is in sleep(1); In this place instead of sleep(1); you should use this:

$this->waitForCondition("selenium.isElementPresent(\'css=table:contains(\'FACEBOOK PIC STATIONS\') a:contains(\'delete\')\')", "20000");

And by the way, while you use selenium RC you can reach your delete link with this css (with webdriver it will not work as :contains is not a part of css spec):

$this->click("css=table:contains('FACEBOOK PIC STATIONS') a:contains('delete')");

Also replace all sleep(1); with appropriate waitForCondition commands

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for this but seleium is now returning Invalid response while accessing the Selenium Server at 'localhost:4444/s elenium-server/driver/': missing ) after argument list
@ChrisMccabe probably you missed ) somewhere. Doesn't stack trace point you to problematic line?
its something to do with the waitforcondition line... i copied it over exactly. I got the test to pass by giving the facebook pic stations table an id and and used $this->waitForCondition("selenium.isElementPresent('id=facebook_vid_stations')", "20000");
@ChrisMccabe It seems like ' should be escaped inside waitforcondiditon. You can try my edited answer
0

Install "XPath Checker 4.4" add-ons in Firefox. So for that object you will get proper xpath using this add-ons..

So,

click xpath=xpath for that object

1 Comment

i have done this and the object is found using the xpath checker

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.