CSV and html as one of the column - vb.net
Have csv create but FileHelpers library (but don;t think its important here. However my csv is comma delimeted file. I always make quotes between each field. In my last column i am pulling html code. However when trying to open csv in excel part of my html field column data is going to first column and some data from html is placed in B column in excel Can someone help here and tell me what's wrong? Here's exact example:
Sample csv
Artikelnummer,Vater,Variation1,Variationswert1,Variation2,Variationswert2,Variation3,Variationswert3,Barcode,Artikelname,Artikelname2,Hersteller,KategorieLevel1,KategorieLevel2,KategorieLevel3,KategorieLevel4,KategorieLevel5,Merkmalname1,Merkmalwertname1,Merkmalname2,Merkmalwertname2,Merkmalname3,Merkmalwertname3,Html
"29.1023.1","","Height","WeiB","","","","","","","","","","Kategoria_A","Podkategoria_A","","co tu?","Height","WeiB","","","","","<meta http-equiv=""content-type"" content=""application/xhtml+xml; charset=UTF-8""/>
<b style=""font-size:22pt;"">Überblick:
</b>
<br>
</br>
<table cellpadding=""10"" cellspacing=""10"" align=""left"" style=""font-size:12pt;table-layout:fixed;width:30%;"">
<tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Marke:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">JUSThome
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Serie:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">blabla
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Artikel-Nr.:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">29.1023.1
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Height:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">Zur auswahl
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Material:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">Material_B1
</td>
</tr>
</table><table cellpadding=""10"" cellspacing=""10"" align=""right"" style=""font-size:12pt;table-layout:fixed;width:70%;"">
<tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Abmessungen:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;""></td>
</tr><tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Höhe:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;"">1,00 cm
</td>
</tr><tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Breite:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;"">2,00 cm
</td>
</tr>
</table><div style=""clear:both !important;"">
</div>
<br>
</br>
<b style=""font-size:22pt;"">Abmessungen im Detail:
</b>
<ul>
<li style=""font-size:12pt;"">Höhe: 1,00 cm</li><li style=""font-size:12pt;"">Breite: 2,00 cm</li>
</ul>
<ul>
<li style=""font-size:12pt;"">Kot : kott </li><li style=""font-size:12pt;"">Swinia : swiania </li>
</ul>
<br>
</br>
<b style=""font-size:22pt;"">Sekcja_A:
</b>
<ul>
<li style=""font-size:12pt;"">WK</li><li style=""font-size:12pt;"">ZW</li>
</ul>
<br>
</br>
<b style=""font-size:22pt;"">Sekcja_Design:
</b>
<ul>
<li style=""font-size:12pt;"">NF</li>
</ul>
<br>
</br>
"
"29.1023.2","","Height","WeiB","","","","","","","","","","Kategoria_A","Podkategoria_A","","co tu?","Height","WeiB","","","","","<meta http-equiv=""content-type"" content=""application/xhtml+xml; charset=UTF-8""/>
<b style=""font-size:22pt;"">Überblick:
</b>
<br>
</br>
<table cellpadding=""10"" cellspacing=""10"" align=""left"" style=""font-size:12pt;table-layout:fixed;width:30%;"">
<tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Marke:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">JUSThome
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Serie:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">blabla
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Artikel-Nr.:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">29.1023.2
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Height:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">WeiB
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Material:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">Material_B1
</td>
</tr>
</table><table cellpadding=""10"" cellspacing=""10"" align=""right"" style=""font-size:12pt;table-layout:fixed;width:70%;"">
<tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Abmessungen:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;""></td>
</tr><tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Höhe:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;"">1,00 cm
</td>
</tr><tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Breite:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;"">2,00 cm
</td>
</tr>
</table><div style=""clear:both !important;"">
</div>
<br>
</br>
<b style=""font-size:22pt;"">Abmessungen im Detail:
</b>
<ul>
<li style=""font-size:12pt;"">Höhe: 1,00 cm</li><li style=""font-size:12pt;"">Breite: 2,00 cm</li>
</ul>
<ul>
<li style=""font-size:12pt;"">Kot : kott </li><li style=""font-size:12pt;"">Swinia : swiania </li>
</ul>
<br>
</br>
<b style=""font-size:22pt;"">Sekcja_A:
</b>
<ul>
<li style=""font-size:12pt;"">WK</li><li style=""font-size:12pt;"">ZW</li>
</ul>
<br>
</br>
<b style=""font-size:22pt;"">Sekcja_Design:
</b>
<ul>
<li style=""font-size:12pt;"">NF</li>
</ul>
<br>
</br>
"
"29.1023.3","","Height","WeiB","","","","","","","","","","Kategoria_A","Podkategoria_A","","co tu?","Height","WeiB","","","","","<meta http-equiv=""content-type"" content=""application/xhtml+xml; charset=UTF-8""/>
<b style=""font-size:22pt;"">Überblick:
</b>
<br>
</br>
<table cellpadding=""10"" cellspacing=""10"" align=""left"" style=""font-size:12pt;table-layout:fixed;width:30%;"">
<tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Marke:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">JUSThome
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Serie:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">blabla
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Artikel-Nr.:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">29.1023.3
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Height:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">WeiB
</td>
</tr><tr>
<td width=""40%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Material:</td><td width=""60%"" border=""3"" style=""text-align:left;padding-left:20px;"">Material_B1
</td>
</tr>
</table><table cellpadding=""10"" cellspacing=""10"" align=""right"" style=""font-size:12pt;table-layout:fixed;width:70%;"">
<tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Abmessungen:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;""></td>
</tr><tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Höhe:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;"">1,00 cm
</td>
</tr><tr>
<td width=""20%"" border=""3"" style=""vertical-align:top;text-align:left;padding-left:20px;color:white;background-color: #b4b4b4"">Breite:</td><td width=""80%"" border=""3"" style=""text-align:left;padding-left:20px;"">2,00 cm
</td>
</tr>
</table><div style=""clear:both !important;"">
</div>
<br>
</br>
<b style=""font-size:22pt;"">Abmessungen im Detail:
</b>
<ul>
<li style=""font-size:12pt;"">Höhe: 1,00 cm</li><li style=""font-size:12pt;"">Breite: 2,00 cm</li>
</ul>
<ul>
<li style=""font-size:12pt;"">Kot : kott </li><li style=""font-size:12pt;"">Swinia : swiania </li>
</ul>
<br>
</br>
<b style=""font-size:22pt;"">Sekcja_A:
</b>
<ul>
<li style=""font-size:12pt;"">WK</li><li style=""font-size:12pt;"">ZW</li>
</ul>
<br>
</br>
<b style=""font-size:22pt;"">Sekcja_Design:
</b>
<ul>
<li style=""font-size:12pt;"">NF</li>
</ul>
<br>
</br>
"
This how it looks like in excel. Every data is placed correctly without html part:
That's how it looks like when i open it in excel without any modification (before text to columns option):
It works fine on Excel 2013. See the screen shot. I just saved the content in .csv file and opened in excel.
Since this is not technically an answer I was going to put this as a comment to your question. However, my "reputation" isn't high enough to comment. Ironic that I can answer questions, but not comment on them. Anyway...I copied and pasted your example on my Macbook and saved it as CSV. It opened in Excel fine for me. I have a feeling it's got something to do with the way newlines are treated by Mac vs. PC. Wish I could be more help, but since it opens fine for me I can't really troubleshoot the problem.
Screenshot
Screenshot
Related
How to select html tr elements with a specific td class
I am using selenium to scrape a website, the website has a calendar and i want to get the days out of that calendar that have available times. I have inspected the calendar and found these elements <table class="ui-datepicker-calendar"> <thead> <tr> <th scope="col"><span title="Monday">Mån</span></th> <th scope="col"><span title="Tuesday">Tis</span></th> <th scope="col"><span title="Wednesday">Ons</span></th> <th scope="col"><span title="Thursday">Tor</span></th> <th scope="col"><span title="Friday">Fre</span></th> <th scope="col" class="ui-datepicker-week-end"><span title="Saturday">Lör</span></th> <th scope="col" class="ui-datepicker-week-end"><span title="Sunday">Sön</span></th> </tr> </thead> <tbody> <tr> <td class=" ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">29</span></td> <td class=" ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">30</span></td> <td class=" ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">31</span></td> <td class=" ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">1</span></td> <td class=" ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">2</span></td> <td class=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">3</span></td> <td class=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">4</span></td> </tr> <tr> <td class=" ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">5</span></td> <td class=" ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">6</span></td> <td class=" ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">7</span></td> <td class=" ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">8</span></td> <td class=" ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">9</span></td> <td class=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">10</span></td> <td class=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">11</span></td> </tr> <tr> <td class=" unavailable ui-datepicker-today" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default ui-state-highlight" href="#">12</a></td> <td class=" available" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">13</a></td> <td class=" available" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">14</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">15</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">16</a></td> <td class=" ui-datepicker-week-end unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">17</a></td> <td class=" ui-datepicker-week-end unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">18</a></td> </tr> <tr> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">19</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">20</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">21</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">22</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">23</a></td> <td class=" ui-datepicker-week-end unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">24</a></td> <td class=" ui-datepicker-week-end unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">25</a></td> </tr> <tr> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">26</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">27</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">28</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">29</a></td> <td class=" unavailable" data-handler="selectDay" data-event="click" data-month="8" data-year="2022"><a class="ui-state-default" href="#">30</a></td> <td class=" ui-datepicker-week-end ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">1</span></td> <td class=" ui-datepicker-week-end ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled unavailable"><span class="ui-state-default">2</span></td> </tr> </tbody> </table> as you can see the days that have times available have td class= " available" those are the days I want to save and keep in a list. I have managed to get the day number printed out so I seem to have all the rows saved as elements since when I do avail = driver.find_elements(By.CLASS_NAME,"ui-datepicker-calendar") for elem in avail: print(elem.text) the output I get is 29,30,31,1,2,3,4... How do I only save the rows that have td class= " available"?
UPD Since the parent td class may contain additional class names we can use contains instead of equals and use not to exclude unavailable dates. As following: avail = driver.find_elements(By.XPATH,"//td[not(contains(#class,'unavailable'))]//a[#class='ui-state-default']") for elem in avail: print(elem.text)
Inherit qweb report and replace string odoo 9
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>
Print all lines from account.invoice.line model
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>
selenium not finding correct link using xpath
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
Selenium RC - Having difficulty with Selenium IDE to find a table cell
I hope someone here can help me. Im using selenium to test a page that has an image which when click displays a calendar. I can get as far as clicking the image using browser.click("//center/table/tbody/tr/td[1]/a/img") I got the above path by using the Selenium IDE. The problem is once i click the above image the Selenium IDE does not record what i have clicked after the calendar is shown. Here is the code for the image button <INPUT size='8' CLASS="field-date" TYPE="text" NAME="endQtrDate" VALUE="01/10/2004" ID="endQtrDate" onBlur="this.value=validateFieldValue(this.value,'date_error','endQtrDate',this.form)" onFocus="this.select()" TITLE="Enter date in format dd/mm/yyyy" /> <IMG ALIGN="absmiddle" ALT="Press to show calendar picker" NAME="calendarButton" SRC="../images/buttons/small/calendar.gif" onClick="return showCalendar('endQtrDate', 'dd/MM/yyyy');" /> Unfortunately i cant see the code for the calendar after i click it. The only way i can see it is using the mozilla plugin "Firebug". I managed to get the div layer of which the calendar is displayed. <div class="calendar" style="position: absolute; display: none; left: 234px; top: 416px;"> <table cellspacing="0" cellpadding="0"> <thead> <tr> <td colspan="1" class="button">-</td> <td colspan="6" class="title" style="cursor: move;">October, 2004</td> <td colspan="1" class="button">×</td> </tr> <tr class="headrow"> <td colspan="1" class="button">«</td> <td colspan="1" class="button">‹</td> <td colspan="4" class="button">Today</td> <td colspan="1" class="button">›</td> <td colspan="1" class="button">»</td> </tr> <tr class="daynames"> <td class="name wn">wk</td> <td class="day name">Mon</td> <td class="day name">Tue</td> <td class="day name">Wed</td> <td class="day name">Thu</td> <td class="day name">Fri</td> <td class="name day weekend">Sat</td> <td class="name day weekend">Sun</td> </tr> </thead> <tbody> <tr class="daysrow"> <td class="day wn">40</td> <td class="day"> </td> <td class="day"> </td> <td class="day"> </td> <td class="day"> </td> <td class="day">1</td> <td class="day weekend">2</td> <td class="day weekend">3</td> </tr> <tr class="daysrow"> <td class="day wn">41</td> <td class="day">4</td> <td class="day">5</td> <td class="day">6</td> <td class="day">7</td> <td class="day">8</td> <td class="day weekend">9</td> <td class="day weekend">10</td> </tr> <tr class="daysrow"> <td class="day wn">42</td> <td class="day">11</td> <td class="day">12</td> <td class="day">13</td> <td class="day">14</td> <td class="selected day">15</td> <td class="day weekend">16</td> <td class="day weekend">17</td> </tr> <tr class="daysrow"> <td class="day wn">43</td> <td class="day">18</td> <td class="day">19</td> <td class="day">20</td> <td class="day">21</td> <td class="day">22</td> <td class="day weekend">23</td> <td class="day weekend">24</td> </tr> <tr class="daysrow"> <td class="day wn">44</td> <td class="day">25</td> <td class="day">26</td> <td class="day">27</td> <td class="day">28</td> <td class="day">29</td> <td class="day weekend">30</td> <td class="day weekend">31</td> </tr> <tr class="emptyrow"> <td class="day wn">36</td> <td class="day">30</td> <td class="day">31</td> <td class="day"> </td> <td class="day"> </td> <td class="day"> </td> <td class="day"> </td> <td class="day"> </td> </tr> </tbody> <tfoot> <tr class="footrow"> <td colspan="8" class="ttip" style="cursor: move;">Select date</td> </tr> </tfoot> </table> <div class="combo" style="display: none;"> <div class="label">Jan</div> <div class="label">Feb</div> <div class="label">Mar</div> <div class="label">Apr</div> <div class="label">May</div> <div class="label">Jun</div> <div class="label">Jul</div> <div class="label">Aug</div> <div class="label">Sep</div> <div class="label">Oct</div> <div class="label">Nov</div> <div class="label">Dec</div> </div> <div class="combo" style="display: none;"> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> <div class="label"></div> </div> </div> If you look carefully you will see table cells for dates from 1 to 30th. How can i access these values using Selenium? I can use the IDE as it doesnt record anything when the calendar pops up. The firebug has an option to display the xpath of any tag. I tried it on one of the td tags and it says this is the xpath. /html/body/div/table/thead/tr[2]/td[3] Can i use the above path to determine its value then click on it using selenium? Thanks
To click on the image you can use click | calendarButton and that should load it up for you. From there you will then need to click on items I would then use firebug to see the other items on the page. Edit from extra info: What you need to do then is use xpath=//td[#class="day" and text()="14"] for xpath or for css use css=td.day:contains('14') The css route will be a lot quicker in browsers like Internet Explorer