Can someone give an example of saving a the table from webpage to excel spreadsheet ?
Let's say the page contains this code. Do we need to save each player one by one by css selector ? or we have some magic function which can copy the table class tag?
Eventually, saving them to mysql is my goal. can someone show how to save to to excel spreadsheet ?
<table class="color-alt a-center sobre">
<tbody><tr class="color-5 negri a-bottom">
<td rowspan="2" class="color-5 " width="8%">Rk</td>
<td rowspan="2" class="color-5 a-left">
<div class="left" style="min-width: 120px; max-width:207px; width: 77%">
<div class="left">Player</div>
<div class="right"> (Team)</div>
</div></td>
<td colspan="2"><strong>3-Pointers Made</strong></td>
<td rowspan="2" class="color-5">Gms</td>
</tr>
<tr class="color-5 negri a-bottom">
<td class="negri">Total</td>
<td>Per Game</td>
</tr>
<tr class="a-top ">
<td class="a-center negri ">1</td>
<td class="a-left">
<div class="left negri " style="min-width: 150px">
Stephen Curry
</div>
<div class="left margen-l2 " style="width:111px">(Warriors)</div>
</td>
<td class=" negri "><strong>337</strong></td>
<td>5.3</td>
<td class="">63</td>
</tr>
<tr class="a-top ">
<td class="a-center ">2</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Buddy Hield
</div>
<div class="left margen-l2 " style="width:111px">(Kings)</div>
</td>
<td class=""><strong>282</strong></td>
<td>4.0</td>
<td class="">71</td>
</tr>
<tr class="a-top ">
<td class="a-center ">3</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Damian Lillard
</div>
<div class="left margen-l2 " style="width:111px">(Trail Blazers)</div>
</td>
<td class=""><strong>275</strong></td>
<td>4.1</td>
<td class="">67</td>
</tr>
<tr class="a-top ">
<td class="a-center ">4</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Duncan Robinson
</div>
<div class="left margen-l2 " style="width:111px">(Heat)</div>
</td>
<td class=""><strong>250</strong></td>
<td>3.5</td>
<td class="">72</td>
</tr>
<tr class="a-top ">
<td class="a-center ">5</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Terry Rozier
</div>
<div class="left margen-l2 " style="width:111px">(Hornets)</div>
</td>
<td class=""><strong>222</strong></td>
<td>3.2</td>
<td class="">69</td>
</tr>
<tr class="a-top ">
<td class="a-center ">6</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Joe Harris
</div>
<div class="left margen-l2 " style="width:111px">(Nets)</div>
</td>
<td class=""><strong>211</strong></td>
<td>3.1</td>
<td class="">69</td>
</tr>
<tr class="a-top ">
<td class="a-center ">7</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Jordan Clarkson
</div>
<div class="left margen-l2 " style="width:111px">(Jazz)</div>
</td>
<td class=""><strong>208</strong></td>
<td>3.1</td>
<td class="">68</td>
</tr>
<tr class="a-top ">
<td class="a-center ">8</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Tim Hardaway Jr.
</div>
<div class="left margen-l2 " style="width:111px">(Mavericks)</div>
</td>
<td class=""><strong>207</strong></td>
<td>3.0</td>
<td class="">70</td>
</tr>
<tr class="a-top ">
<td class="a-center ">9</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Zach LaVine
</div>
<div class="left margen-l2 " style="width:111px">(Bulls)</div>
</td>
<td class=""><strong>200</strong></td>
<td>3.4</td>
<td class="">58</td>
</tr>
<tr class="a-top ">
<td class="a-center ">10</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Luka Doncic
</div>
<div class="left margen-l2 " style="width:111px">(Mavericks)</div>
</td>
<td class=""><strong>192</strong></td>
<td>2.9</td>
<td class="">66</td>
</tr>
<tr class="a-top ">
<td class="a-center ">11</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Jayson Tatum
</div>
<div class="left margen-l2 " style="width:111px">(Celtics)</div>
</td>
<td class=""><strong>187</strong></td>
<td>2.9</td>
<td class="">64</td>
</tr>
<tr class="a-top ">
<td class="a-center ">12</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Joe Ingles
</div>
<div class="left margen-l2 " style="width:111px">(Jazz)</div>
</td>
<td class=""><strong>183</strong></td>
<td>2.7</td>
<td class="">67</td>
</tr>
<tr class="a-top ">
<td class="a-center ">13</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Bojan Bogdanovic
</div>
<div class="left margen-l2 " style="width:111px">(Jazz)</div>
</td>
<td class=""><strong>180</strong></td>
<td>2.5</td>
<td class="">72</td>
</tr>
<tr class="a-top ">
<td class="a-center ">14</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Devonte' Graham
</div>
<div class="left margen-l2 " style="width:111px">(Hornets)</div>
</td>
<td class=""><strong>179</strong></td>
<td>3.3</td>
<td class="">55</td>
</tr>
<tr class="a-top ">
<td class="a-center ">15</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Donovan Mitchell
</div>
<div class="left margen-l2 " style="width:111px">(Jazz)</div>
</td>
<td class=""><strong>178</strong></td>
<td>3.4</td>
<td class="">53</td>
</tr>
<tr class="a-top ">
<td class="a-center ">16</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Nikola Vucevic
</div>
<div class="left margen-l2 " style="width:111px">(2 teams)</div>
</td>
<td class=""><strong>176</strong></td>
<td>2.5</td>
<td class="">70</td>
</tr>
<tr class="a-top ">
<td class="a-center ">17</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Saddiq Bey
</div>
<div class="left margen-l2 " style="width:111px">(Pistons)</div>
</td>
<td class=""><strong>175</strong></td>
<td>2.5</td>
<td class="">70</td>
</tr>
<tr class="a-top ">
<td class="a-center "></td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Danny Green
</div>
<div class="left margen-l2 " style="width:111px">(76ers)</div>
</td>
<td class=""><strong>175</strong></td>
<td>2.5</td>
<td class="">69</td>
</tr>
<tr class="a-top ">
<td class="a-center ">19</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Fred VanVleet
</div>
<div class="left margen-l2 " style="width:111px">(Raptors)</div>
</td>
<td class=""><strong>174</strong></td>
<td>3.3</td>
<td class="">52</td>
</tr>
<tr class="a-top ">
<td class="a-center ">20</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Justin Holiday
</div>
<div class="left margen-l2 " style="width:111px">(Pacers)</div>
</td>
<td class=""><strong>173</strong></td>
<td>2.4</td>
<td class="">72</td>
</tr>
<tr class="a-top ">
<td class="a-center ">21</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Lonzo Ball
</div>
<div class="left margen-l2 " style="width:111px">(Pelicans)</div>
</td>
<td class=""><strong>172</strong></td>
<td>3.1</td>
<td class="">55</td>
</tr>
<tr class="a-top ">
<td class="a-center ">22</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Anthony Edwards
</div>
<div class="left margen-l2 " style="width:111px">(Timberwolves)</div>
</td>
<td class=""><strong>171</strong></td>
<td>2.4</td>
<td class="">72</td>
</tr>
<tr class="a-top ">
<td class="a-center "></td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Paul George
</div>
<div class="left margen-l2 " style="width:111px">(Clippers)</div>
</td>
<td class=""><strong>171</strong></td>
<td>3.2</td>
<td class="">54</td>
</tr>
<tr class="a-top ">
<td class="a-center "></td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Norman Powell
</div>
<div class="left margen-l2 " style="width:111px">(2 teams)</div>
</td>
<td class=""><strong>171</strong></td>
<td>2.5</td>
<td class="">69</td>
</tr>
<tr class="a-top ">
<td class="a-center ">25</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Michael Porter Jr.
</div>
<div class="left margen-l2 " style="width:111px">(Nuggets)</div>
</td>
<td class=""><strong>170</strong></td>
<td>2.8</td>
<td class="">61</td>
</tr>
<tr class="a-top ">
<td class="a-center ">26</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Davis Bertans
</div>
<div class="left margen-l2 " style="width:111px">(Wizards)</div>
</td>
<td class=""><strong>169</strong></td>
<td>3.0</td>
<td class="">57</td>
</tr>
<tr class="a-top ">
<td class="a-center "></td>
<td class="a-left">
<div class="left " style="min-width: 150px">
C.J. McCollum
</div>
<div class="left margen-l2 " style="width:111px">(Trail Blazers)</div>
</td>
<td class=""><strong>169</strong></td>
<td>3.6</td>
<td class="">47</td>
</tr>
<tr class="a-top ">
<td class="a-center ">28</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Gary Trent Jr.
</div>
<div class="left margen-l2 " style="width:111px">(2 teams)</div>
</td>
<td class=""><strong>165</strong></td>
<td>2.8</td>
<td class="">58</td>
</tr>
<tr class="a-top ">
<td class="a-center ">29</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Jaylen Brown
</div>
<div class="left margen-l2 " style="width:111px">(Celtics)</div>
</td>
<td class=""><strong>163</strong></td>
<td>2.8</td>
<td class="">58</td>
</tr>
<tr class="a-top ">
<td class="a-center "></td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Reggie Bullock
</div>
<div class="left margen-l2 " style="width:111px">(Knicks)</div>
</td>
<td class=""><strong>163</strong></td>
<td>2.5</td>
<td class="">65</td>
</tr>
<tr class="a-top ">
<td class="a-center "></td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Coby White
</div>
<div class="left margen-l2 " style="width:111px">(Bulls)</div>
</td>
<td class=""><strong>163</strong></td>
<td>2.4</td>
<td class="">69</td>
</tr>
<tr class="a-top ">
<td class="a-center ">32</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Patty Mills
</div>
<div class="left margen-l2 " style="width:111px">(Spurs)</div>
</td>
<td class=""><strong>161</strong></td>
<td>2.4</td>
<td class="">68</td>
</tr>
<tr class="a-top ">
<td class="a-center ">33</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Julius Randle
</div>
<div class="left margen-l2 " style="width:111px">(Knicks)</div>
</td>
<td class=""><strong>160</strong></td>
<td>2.3</td>
<td class="">71</td>
</tr>
<tr class="a-top ">
<td class="a-center ">34</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Bryn Forbes
</div>
<div class="left margen-l2 " style="width:111px">(Bucks)</div>
</td>
<td class=""><strong>154</strong></td>
<td>2.2</td>
<td class="">70</td>
</tr>
<tr class="a-top ">
<td class="a-center ">35</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Kyrie Irving
</div>
<div class="left margen-l2 " style="width:111px">(Nets)</div>
</td>
<td class=""><strong>152</strong></td>
<td>2.8</td>
<td class="">54</td>
</tr>
<tr class="a-top ">
<td class="a-center ">36</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Khris Middleton
</div>
<div class="left margen-l2 " style="width:111px">(Bucks)</div>
</td>
<td class=""><strong>151</strong></td>
<td>2.2</td>
<td class="">68</td>
</tr>
<tr class="a-top ">
<td class="a-center ">37</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Jae Crowder
</div>
<div class="left margen-l2 " style="width:111px">(Suns)</div>
</td>
<td class=""><strong>148</strong></td>
<td>2.5</td>
<td class="">60</td>
</tr>
<tr class="a-top ">
<td class="a-center ">38</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Bogdan Bogdanovic
</div>
<div class="left margen-l2 " style="width:111px">(Hawks)</div>
</td>
<td class=""><strong>146</strong></td>
<td>3.3</td>
<td class="">44</td>
</tr>
<tr class="a-top ">
<td class="a-center ">39</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Malcolm Brogdon
</div>
<div class="left margen-l2 " style="width:111px">(Pacers)</div>
</td>
<td class=""><strong>145</strong></td>
<td>2.6</td>
<td class="">56</td>
</tr>
<tr class="a-top ">
<td class="a-center ">40</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Brandon Ingram
</div>
<div class="left margen-l2 " style="width:111px">(Pelicans)</div>
</td>
<td class=""><strong>143</strong></td>
<td>2.3</td>
<td class="">61</td>
</tr>
<tr class="a-top ">
<td class="a-center ">41</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Kevin Huerter
</div>
<div class="left margen-l2 " style="width:111px">(Hawks)</div>
</td>
<td class=""><strong>140</strong></td>
<td>2.0</td>
<td class="">69</td>
</tr>
<tr class="a-top ">
<td class="a-center "></td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Marcus Morris
</div>
<div class="left margen-l2 " style="width:111px">(Clippers)</div>
</td>
<td class=""><strong>140</strong></td>
<td>2.5</td>
<td class="">57</td>
</tr>
<tr class="a-top ">
<td class="a-center "></td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Andrew Wiggins
</div>
<div class="left margen-l2 " style="width:111px">(Warriors)</div>
</td>
<td class=""><strong>140</strong></td>
<td>2.0</td>
<td class="">71</td>
</tr>
<tr class="a-top ">
<td class="a-center ">44</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Mike Conley
</div>
<div class="left margen-l2 " style="width:111px">(Jazz)</div>
</td>
<td class=""><strong>138</strong></td>
<td>2.7</td>
<td class="">51</td>
</tr>
<tr class="a-top ">
<td class="a-center ">45</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Kyle Kuzma
</div>
<div class="left margen-l2 " style="width:111px">(Lakers)</div>
</td>
<td class=""><strong>137</strong></td>
<td>2.0</td>
<td class="">68</td>
</tr>
<tr class="a-top ">
<td class="a-center ">46</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Trae Young
</div>
<div class="left margen-l2 " style="width:111px">(Hawks)</div>
</td>
<td class=""><strong>136</strong></td>
<td>2.2</td>
<td class="">63</td>
</tr>
<tr class="a-top ">
<td class="a-center ">47</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Robert Covington
</div>
<div class="left margen-l2 " style="width:111px">(Trail Blazers)</div>
</td>
<td class=""><strong>135</strong></td>
<td>1.9</td>
<td class="">70</td>
</tr>
<tr class="a-top ">
<td class="a-center ">48</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Mikal Bridges
</div>
<div class="left margen-l2 " style="width:111px">(Suns)</div>
</td>
<td class=""><strong>134</strong></td>
<td>1.9</td>
<td class="">72</td>
</tr>
<tr class="a-top ">
<td class="a-center ">49</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Carmelo Anthony
</div>
<div class="left margen-l2 " style="width:111px">(Trail Blazers)</div>
</td>
<td class=""><strong>133</strong></td>
<td>1.9</td>
<td class="">69</td>
</tr>
<tr class="a-top ">
<td class="a-center ">50</td>
<td class="a-left">
<div class="left " style="min-width: 150px">
Here is how you can save data in an Excel file:
import xlsxwriter
import mysql.connector
Here is the main parser:
def parse(self, response):
for x in response.xpath("//table//tr[#class='a-top']"):
serial_code = x.xpath("./td[1]/text()").get()
team_name = x.xpath("./td[2]/div[1]/a/text()").get()
team_href = x.xpath("./td[2]/div[1]/a/#href").get()
team_title = x.xpath("./td[2]/div[2]/text()").get()
total_points = x.xpath("./td[3]/strong/text()").get()
per_game = x.xpath("./td[4]/text()").get()
total_games = x.xpath("./td[5]/text()").get()
response.meta['serial_code'] = serial_code
response.meta['team_name'] = team_name
response.meta['team_href'] = team_href
response.meta['team_title'] = team_title
response.meta['total_points'] = total_points
response.meta['per_game'] = per_game
response.meta['total_games'] = total_games
yield response.meta
Here is the pipeline.py:
class PlayersExcelPipeline(object):
rowNumb = 0
workbook = xlsxwriter.Workbook('Players-Data.xlsx')
worksheet = workbook.add_worksheet("Final Data")
worksheet.set_zoom(80)
def __init__(self):
self.rowNumb += 1
self.worksheet.write( "A%s" % self.rowNumb, "serial_code" )
self.worksheet.write( "B%s" % self.rowNumb, "team_name" )
self.worksheet.write( "C%s" % self.rowNumb, "team_href" )
self.worksheet.write( "D%s" % self.rowNumb, "team_title" )
self.worksheet.write( "E%s" % self.rowNumb, "total_points" )
self.worksheet.write( "F%s" % self.rowNumb, "per_game" )
self.worksheet.write( "G%s" % self.rowNumb, "total_games" )
def process_item(self, item, spider):
self.rowNumb += 1
self.worksheet.write_string( "A%s" % self.rowNumb, item["serial_code"] )
self.worksheet.write_string( "B%s" % self.rowNumb, item["team_name"] )
self.worksheet.write_string( "C%s" % self.rowNumb, item["team_href"] )
self.worksheet.write_string( "D%s" % self.rowNumb, item["team_title"] )
self.worksheet.write_string( "E%s" % self.rowNumb, item["total_points"] )
self.worksheet.write_string( "F%s" % self.rowNumb, item["per_game"] )
self.worksheet.write_string( "G%s" % self.rowNumb, item["total_games"] )
def __del__(self):
self.workbook.close()
Once you visualize how data is saved in an Excel file, it should be relatively easier to save same in MySQL database. Here is how it may look:
class PlayersMySQLPipeline(object):
credentials = ["localhost","user","password","database"]
def __init__(self):
self.mydb = mysql.connector.connect(host=self.credentials[0], user=credentials[1], passwd=self.credentials[2], database=self.credentials[3])
self.mycursor = self.mydb.cursor()
def process_item(self, item, spider):
sql = """your insert sql query goes here"""
self.mycursor.execute(sql)
self.mydb.commit()
print ("record inserted")
def __del__(self):
self.mycursor.close()
Related
I'm inherit qweb report, now I want replace string Total Without Taxes, Taxes, Total
<div class="row" name="total">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="doc.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="doc.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="doc.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</div>
<xpath expr="?????" position="replace">
</xpath>
Any simple solution or online example?..................................
please try this code :-
<xpath expr="//div[#name='total']" position="replace">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<!--Add your Custom String-->
<td><strong>Custom String</strong></td>
<td class="text-right">
<span t-field="doc.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<!--Add your Custom String for taxes-->
<td>Custom String</td>
<td class="text-right">
<span t-field="doc.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<!--Add your Custom String for Total-->
<td><strong>Custom String</strong></td>
<td class="text-right">
<span t-field="doc.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</xpath>
Try this. Havent had a chance to test it.
<xpath expr="//table[contains(#class, 'table-condensed')]/tr[first()]/td[first()]" position="replace">
<!-- YOUR XML HERE -->
</xpath>
I am new to bootstrap. What can I do to see all the contents of my page when screens are smaller. My table in Activities panel doesn't adjust with the screen size.I have a div named MiddleDiv where I append 1 or more tables on the fly.
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 col-xs-12">
<div class="panel panel-primary">
<div class="panel-heading">Activities</div>
<div class="panel-body">
<div class="table-responsive" id="MiddleDiv">
<table width="100%" style="margin-bottom:10px" id="Table_1" class="TableBlankClass table">
<tbody>
<tr class="bg-success">
<td style="font-weight:bold" id="ActivityCompany_1" colspan="3">Company(Bill to): TD General Insurance Company</td>
<td style="font-weight:bold" id="ActivityClient_1" colspan="6">Client: Test Adjsuter</td>
</tr>
<tr>
<td colspan="3">
<table width="100%">
<tbody>
<tr>
<td><button class="btn btn-danger btn-xs" id="ActivityDel_1" onclick="DelActivity('Table_1')" type="button">Del</button></td>
<td class="ActivitiesHeading">Activity</td>
<td>
<select onchange="GetRate('Table_1')" id="ActivityTypeDropDown_1" style="width:200px;" class="form-control TableSelectClass">
<option value="- Select One -" selected="">- Select One -</option>
<option value="Accomodation">Accomodation</option>
</select>
</td>
</tr>
</tbody>
</table>
</td>
<td class="ActivitiesHeading">Comments</td>
<td colspan="2" class="ActivitiesHeading"><textarea rows="1" style="width: 275px; height: 35px;" class="form-control" id="ActivityComments_1"></textarea></td>
<td class="ActivitiesHeading">Status<span id="ActivitySpan_1"></span></td>
<td colspan="2" class="ActivitiesHeading">
<select onchange="CalculateActivities(); CreateRemoveReasonButton('Table_1');" id="ActivityStatusDropDown_1" style="width:200px;" class="form-control">
<option value="24859" selected="">Waiting To Process Payer Invoice</option>
</select>
</td>
</tr>
<tr>
<td class="ActivitiesHeading">Rate</td>
<td class="ActivitiesHeading">Qty</td>
<td class="ActivitiesHeading">Discount</td>
<td class="ActivitiesHeading">Discount %</td>
<td class="ActivitiesHeading">Reason For Discount</td>
<td class="ActivitiesHeading">Tax Applicable</td>
<td class="ActivitiesHeading">Taxes</td>
<td class="ActivitiesHeading">SubTotal</td>
<td class="ActivitiesHeading">Gross Total</td>
</tr>
<tr>
<td><input type="text" onblur="if (this.value=='') {this.value = 0;}" value="0" onkeyup="CalculateActivities()" id="ActivityRate_1" class="form-control TableNumericClass"></td>
<td><input type="text" onblur="if (this.value=='' || this.value=='0') {this.value = 1;}" value="1" onkeyup="CalculateActivities()" id="ActivityQty_1" class="form-control TableNumericClass"></td>
<td><input type="text" onblur="if (this.value=='0') {this.value = '';}" value="" onkeyup="CalculateActivities()" id="ActivityDiscount_1" class="form-control TableDiscountClass"></td>
<td><input type="text" onblur="if (this.value=='0') {this.value = '';}" value="" onkeyup="CalculateActivities()" id="ActivityDiscountPercentage_1" class="form-control TableDiscountClass"></td>
<td>
<select id="ReasonForDiscountDropDown_1" class="form-control">
<option value="- Select One -" selected="">- Select One -</option>
<option value="Late Report Delivery">Late Report Delivery</option>
<option value="Incorrect File Management">Incorrect File Management</option>
<option value="Client Satisfaction">Client Satisfaction</option>
<option value="Other - See Service Notes">Other - See Service Notes</option>
</select>
</td>
<td>
<select onchange="CalculateActivities()" id="ActivityTaxApplicable_1" class="form-control">
<option value="Yes" selected="">Yes</option>
<option value="No">No</option>
</select>
</td>
<td><img width="15" height="15" title="<body> <table width="150px" border="0" cellspacing="1" cellpadding="1"> <tr> <td class="ToolTipTableClass">Tax1 :</td> <td class="ToolTipTableClass">0.00</td> </tr> <tr> <td class="ToolTipTableClass">Tax2 :</td> <td class="ToolTipTableClass" >0.00</td> </tr> </table> </body>" src="/files/404048/93171/Info-32.png" id="ActivityTaxesAmount_1" class="TaxesClass" data-original-title="<body> <table width="150px" border="0" cellspacing="1" cellpadding="1"> <tr> <td class="ToolTipTableClass">Tax1 :</td> <td class="ToolTipTableClass"></td> </tr> <tr> <td class="ToolTipTableClass">Tax2 :</td> <td class="ToolTipTableClass" ></td> </tr> </table> </body>"></td>
<td id="ActivitySubTotal_1">100.00</td>
<td id="ActivityGrossTotal_1">100.00</td>
</tr>
<tr>
<td class="ActivitiesHeading">Measure</td>
<td colspan="2" class="ActivitiesHeading">GAP Code</td>
<td colspan="3" class="ActivitiesHeading">Other Description</td>
<td colspan="3" class="ActivitiesHeading"> </td>
</tr>
<tr>
<td>
<select id="ActivityMeasure_1" class="form-control">
<option selected="" value="- Select One -">- Select One -</option>
</select>
</td>
<td colspan="2">
<select id="ActivityGAPCode_1" class="form-control">
<option value="00000" selected=""><-Select One-></option>
</select>
</td>
<td colspan="3"><input type="text" id="ActivityOtherDescription_1" class="form-control"></td>
<td colspan="3">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 col-xs-12">
<div class="panel panel-primary">
<div class="panel-heading">Total</div>
<div class="panel-body">
<div class="table-responsive">
<table width="100%" class="table">
<tbody>
<tr>
<td class="HeadingTD">SubTotal</td>
<td id="AllSubTotal"></td>
<td class="HeadingTD">Discount</td>
<td id="AllDiscount"></td>
<td class="HeadingTD">Tax</td>
<td id="AllTax"></td>
<td class="HeadingTD">Gross Total</td>
<td id="AllGrossTotal"></td>
</tr>
<tr>
<td colspan="2" id="AddItemTD"></td>
<td colspan="2" id="SubmitActivitiesTD"></td>
<td colspan="2" id="VoidInvoiceTD"></td>
<td colspan="2" align="right"><button class="btn btn-primary btn-sm" onclick="window.parent.close()" type="button">Close</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
I can see you are just wrapping traditional HTML tables with some bootstrap classes expecting them to be responsive.
It's a good start but you need to rethink how you construct your tables when you use bootstrap.
Bootstrap uses their "Grid System" http://getbootstrap.com/css/#grid
The grid system doesn't use tables at all. It uses divs with specific classes on them achieve the layout you are looking for. Until you fully use the bootstrap grid system you will not truly see a responsive design.
Take the time to learn the bootstrap grid system.
A bit of a side note and personal opinion: Looking at your form design (which looks great btw) you might not like the result of a responsive design. All of the form fields will end up stacking on top of each other. This form design really only works horizontally. If it were vertically aligned it might get very confusing. If it were me, I might design the form to fit interfaces as small as a tablet but not mobile.
I created a new template for printing, and i want to customize it so it prints all the lines from account.invoice.line model. Is there a way you can do that. Here is the code of the template so far.
<t t-name="account.specifikacioni_report_document">
<t t-call="report.external_layout">
<div class="page">
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th>Quantity</th>
<th class="text-right">Unit Price</th>
<th class="text-right" groups="sale.group_discount_per_so_line">Discount (%)</th>
<th class="text-right">Taxes</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line" t-as="l">
<td>
<span t-field="l.name"/>
</td>
<td>
<span t-field="l.quantity"/>
<span t-field="l.uos_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: x.name, l.invoice_line_tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal" t-field-options="{"widget": "monetary", "display_currency": "o.currency_id"}"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
This prints invoice lines for one invoice cause I copied the account.report_invoice_document and just edited it, but how can I list all invoice lines here not only the invoice lines for an invoice
You can follow the report_invoice.xml to print the lines.
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th>Quantity</th>
<th class="text-right">Unit Price</th>
<th class="text-right" groups="sale.group_discount_per_so_line">Discount (%)</th>
<th class="text-right">Taxes</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line" t-as="l">
<td><span t-field="l.name"/></td>
<td>
<span t-field="l.quantity"/>
<span t-field="l.uos_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td class="text-right" groups="sale.group_discount_per_so_line"><span t-field="l.discount"/></td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: x.name, l.invoice_line_tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
</tbody>
</table>
I am trying to find the text and if the text is found then click the Edit link which is in the td tag.... but when you look at the page source I dont see how to determine any recommendation or suggestions to achieve?
for an example:
in my page html source (see below) in the td i have text called Title1 once I found the text then I want to find a way to click on the Edit link (which is a hyperlink)
here is what i have done so far
//here is my code
IWebDriver driver = new OpenQA.Selenium.IE.InternetExplorerDriver();
string url ="http://site.com";
driver.Navigate().GoToUrl(url);
string pagesource = driver.PageSource;
//html page source:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head id="ctl00_PageHead">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Employee </title>
<body id="ctl00_PageBody">
<form name="aspnetForm" method="post" action="login.aspx" id="aspnetForm" class="container">
<div>
</div>
<div>
</div>
<table class="global-table" cellpadding="0" cellspacing="0">
<tr class="body">
<td>
<div id="body">
<div id="body-inner">
<h1>
Employee Information</h1>
<div id="ctl00_ContentPlaceHolder1_Control1_pnlList" style="width: 100%;">
<div class='filter'>
Language:
<select name="ctl00$ContentPlaceHolder1$Control1$ddlLanguage" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$Control1$ddlLanguage\',\'\')', 0)"
id="ctl00_ContentPlaceHolder1_Control1_ddlLanguage">
<option selected="selected" value="1">English</option>
</select></div>
<div>
<table class="gv" cellspacing="0" border="0" id="ctl00_ContentPlaceHolder1_Control1_gv"
style="border-collapse: collapse;">
<tr class="gridHeader">
<td colspan="8">
<div style="float: left; margin-left: 7px; margin-top: 0px;">
<div style="float: left;">
<input type="image" name="ctl00$ContentPlaceHolder1$Control1$gv$ctl01$ibtnFirst"
id="ctl00_ContentPlaceHolder1_Control1_gv_ctl01_ibtnFirst" disabled="disabled"
title="First Page" src="../App_Themes/Default/images/grid_page_first.png" style="border-width: 0px;
opacity: 0.4; filter: alpha(opacity=40); cursor: default;" />
<input type="image" name="ctl00$ContentPlaceHolder1$Control1$gv$ctl01$ibtnPrev" id="ctl00_ContentPlaceHolder1_Control1_gv_ctl01_ibtnPrev"
disabled="disabled" title="Previous Page" src="../App_Themes/Default/images/grid_page_prev.png"
style="border-width: 0px; opacity: 0.4; filter: alpha(opacity=40); cursor: default;" />
</div>
<div style="float: left; padding: 3px 5px 0px 5px;">
<div class="pagerNumber">
Page 1 of 34
</div>
</div>
<div style="float: left;">
<input type="image" name="ctl00$ContentPlaceHolder1$Control1$gv$ctl01$ibtnNext" id="ctl00_ContentPlaceHolder1_Control1_gv_ctl01_ibtnNext"
title="Next Page" src="../App_Themes/Default/images/grid_page_next.png" style="border-width: 0px;" />
<input type="image" name="ctl00$ContentPlaceHolder1$Control1$gv$ctl01$ibtnLast" id="ctl00_ContentPlaceHolder1_Control1_gv_ctl01_ibtnLast"
title="Last Page" src="../App_Themes/Default/images/grid_page_last.png" style="border-width: 0px;" />
</div>
</div>
<div style="float: left; margin: 0px 6px 0px 20px;">
Page Size
<select name="ctl00$ContentPlaceHolder1$Control1$gv$ctl01$ddlPageSize" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$Control1$gv$ctl01$ddlPageSize\',\'\')', 0)"
id="ctl00_ContentPlaceHolder1_Control1_gv_ctl01_ddlPageSize">
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
<div id="ctl00_ContentPlaceHolder1_Control1_gv_ctl01_RecordCount" style="float: right;
padding-right: 10px; margin-top: 3px;">
<b>10</b> Items Found</div>
</td>
</tr>
<tr class="header">
<th class=" nolink" scope="col">
</th>
<th scope="col">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Sort$Phone')">
Phone</a>
</th>
<th class=" sorted-desc" scope="col">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Sort$Title')">
Title</a>
</th>
<th scope="col">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Sort$SubTitle')">
SubTitle</a>
</th>
<th scope="col">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Sort$Names')">
Names</a>
</th>
<th scope="col">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Sort$Names')">
Enames</a>
</th>
<th scope="col">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Sort$Active')">
Active</a>
</th>
<th scope="col">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Sort$DateTime')">
DateTime</a>
</th>
</tr>
<tr class="item">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$0')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
Title1
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
8/23/2011
</td>
</tr>
<tr class="altItem">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$1')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
1
</td>
<td>
1
</td>
<td>
Employee
</td>
<td>
</td>
<td>
</td>
<td>
7/31/2014
</td>
</tr>
<tr class="item">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$2')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
111
</td>
<td>
111
</td>
<td>
Employer
</td>
<td>
</td>
<td>
</td>
<td>
7/31/2013
</td>
</tr>
<tr class="altItem">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$3')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
123
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
8/23/2011
</td>
</tr>
<tr class="item">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$4')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
2
</td>
<td>
2
</td>
<td>
Employer
</td>
<td>
</td>
<td>
</td>
<td>
7/31/2012
</td>
</tr>
<tr class="altItem">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$5')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
3
</td>
<td>
3
</td>
<td>
Employer
</td>
<td>
</td>
<td>
</td>
<td>
7/31/2012
</td>
</tr>
<tr class="item">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$6')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
a
</td>
<td>
a
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
7/20/2012
</td>
</tr>
<tr class="altItem">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$7')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
Day
</td>
<td>
</td>
<td>
Customer
</td>
<td>
</td>
<td>
</td>
<td>
3/2/2013
</td>
</tr>
<tr class="item">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$8')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
a1
</td>
<td>
a1
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
7/24/20/14
</td>
</tr>
<tr class="altItem">
<td align="center">
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Control1$gv','Select$9')">
Edit</a>
</td>
<td align="center" style="width: 15px;">
</td>
<td>
A1
</td>
<td>
A1
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
7/30/2012
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</td>
</tr>
<tr class="footer">
<td>
</td>
</tr>
</table>
</form>
</body>
</html>
Why wouldn't the following work?
// Assumes "driver" is a valid object implementing IWebDriver
IWebElement table = driver.FindElement(By.ClassName("gv"));
IWebElement element = table.FindElement(By.XPath(".//td[contains(., 'Title1')]/..//a"));
In essence, this says, "Starting at the table with the class name "gv", find the <td> element whose text contains 'Title1', navigate to it's parent (which should be the <tr> element), then find the first <a> descendent element."
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">HOME </li>
<li rel="retail">
RETAIL </li>
<li rel="stats"> STATS</li>
<li
rel="social_media_settings"> SETTINGS</li>
<li rel="logout">LOGOUT </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>USERS</li>
<li>COMPETITIONS</li>
</ul>
</div>
<div id="home" class="submenustyle">
<ul class="sub_menu">
<li>ADD LIKESTATION</li>
<li>ADD PICSTATION</li>
<li>ADD VIDSTATION</li>
</ul>
</div>
<div id="socialmedia_users" class="submenustyle">
</div>
<div id="stats" class="submenustyle">
<ul class="sub_menu">
<li>STATS HOME</li>
<li>FACEBOOK STATS</li>
</ul>
</div>
<div id="social_media_settings" class="submenustyle">
<ul class="sub_menu">
<li>SETTINGS HOME</li>
<li>NETWORKS TO USE</li>
<li>PRE REGISTRATION</li>
<li>
APP SETTINGS
</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>http://localhost/upd8r_new/retail/register/80</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>gla20311344 </td>
<td>http://localhost/upd8r_new/socialmedia/edit/gla20311344 </td>
<td>Webcast </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla2084629867 </td>
<td>http://localhost/upd8r_new/socialmedia/edit/gla2084629867 </td>
<td>tes this link title3 </td>
<td>STATS </td>
<td>4 weeks ago</td>
<td>delete</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>gla1079978359 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>**link I'm trying to click**delete</td>
</tr>
<tr>
<td>gla1229158969 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla1256364596 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla1529784490 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla159062284 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla175038477 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla1777127061 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla180142977 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla1950664292 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla1971709701 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla2028774169 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla2035285297 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla2072665757 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla2115042517 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla2141659529 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla4705592 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla565900575 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla608150382 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</td>
</tr>
<tr>
<td>gla979271929 </td>
<td>Test title 2 </td>
<td>STATS </td>
<td>0</td>
<td>delete</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>
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
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