Add string in html vb - vb.net

I want to put a string on HTML content.I have the next code
<table>
<tr>
<td>hi</td>
</tr>
<tr class="pem">
<td>hello</td>
</tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>hi</td>
</tr>
<tr class="pem">
<td>hello</td>
</tr>
<td>1</td>
<td>2</td>
</tr>
</table>
So if you see, I need to put 2 "tr" to close it.
I think i need to make a for like this:
for each node as htmlNode in doc.DocumentNode.SelectNodes("//tr[contains(#class,'pem')]")
//And here i want to make a appendchild to put only the "tr" to open it
node.appendChild("<tr>")
But it doesn't work because I need to make an HTML node or htmlElement

You need to use CDATA tags in order to insert html elements in xml.
An example would be:
<xml>
<title>Your HTML title</title>
<htmlData><![CDATA[<html>
<head>
<script/>
</head>
<body>
Your HTML's body
</body>
</html>
]]>
</htmlData>
</xml>

Related

How can display table Section in every page like thead

I am trying to display table title with <section> tag in every page like <thead> tag as per below HTML script, But it's not displaying section tag
on every page. Is there any solution for this?
<table class="zebra">
<caption>Table caption goes here</caption>
<thead>
<tr>
<th>Title1</th>
<th>Title2</th>
<th>Title3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row1</td>
<td>Row2</td>
<td>167.00</td>
</tr>
<tr>
<td>Row2</td>
<td>Row2</td>
<td>444.53</td>
</tr>
<tr>
...... untill second page
</tr>
</tbody>
</table>

Pandas DataFrame styled for presentation

In Pandas and Seaborn we can create beautiful graphical displays. However sometimes the best thing to show are numbers, for example in a data frame or pivot table.
Are there tools available to generate a similarly attractive display of numbers? (Yes, I suppose I can export to word or excel but that would have been true for beautiful graphs too...)
I'd say it depends on your definition of attractive, but one can make simple clean looking tables from pandas using the pandas.DataFrame.to_html() function. Combine this with custom CSS, or Bootstrap CSS as below, and the results are decent.
import pandas as pd
sample_df = pd.DataFrame({'Column A': [1,2,3,4,5], 'Column B': [5,4,3,2,1], 'Column C': [100,200,300,400,500]})
with open('test_table.html', 'w') as f:
f.write(sample_df.to_html())
Then simply edit the output html with some CSS, in this case Bootstrap.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row mt-5">
<div class="col">
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th>Column A</th>
<th>Column B</th>
<th>Column C</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>1</td>
<td>5</td>
<td>100</td>
</tr>
<tr>
<th>1</th>
<td>2</td>
<td>4</td>
<td>200</td>
</tr>
<tr>
<th>2</th>
<td>3</td>
<td>3</td>
<td>300</td>
</tr>
<tr>
<th>3</th>
<td>4</td>
<td>2</td>
<td>400</td>
</tr>
<tr>
<th>4</th>
<td>5</td>
<td>1</td>
<td>500</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
Resulting in something simple looking like this:
Which could be saved to PDF etc.

While generating PDF in ColdFusion, Rowspan is not working properly for RTL direction (ex: Arabic)

I have a table structure in HTML where I have to use rowspan and RTL(Right To Left) direction for Arabic characters. But while converting this HTML to PDF, rowspan is not working as expected. Assuming this is a bug in ColdFusion where an HTML with rowsapn and RTL direction is not working correctly.
Note that this is working fine for LTR (Left To Right) direction (ex: English Characters). But I need to use RTL direction since Arabic characters need to be displayed in PDF.
Any idea why this is not working?
Sample Code :
<cfdocument format="PDF" filename="C:\test.pdf" overwrite="true">
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
table#mainTable {direction:rtl;}
</style>
</head>
<body>
<cfoutput>
<table id="mainTable">
<tr>
<td>Tariff</td>
<td>Description</td>
<td>Quantity</td>
<td>Unit Price</td>
<td>Amount</td>
</tr>
<tr>
<td rowspan="7" >Customer Level Charges</td>
<td>9999123456</td>
<td>18.16</td>
<td>6</td>
<td>108.96</td>
</tr>
<tr>
<td>9999123456</td>
<td>18.16</td>
<td>6</td>
<td>108.96</td>
</tr>
<tr>
<td>9999123456</td>
<td>18.16</td>
<td>6</td>
<td>108.96</td>
</tr>
<tr>
<td>Adjustments</td>
<td colspan="4">-20</td>
</tr>
<tr>
<td>This Month Amount</td>
<td colspan="4">1091.92</td>
</tr>
<tr>
<td>Last Month outstanding Amount</td>
<td colspan="4">0</td>
</tr>
<tr>
<td>Total</td>
<td colspan="4">1146.51</td>
</tr>
</table>
</cfoutput>
</body>
</html>
</cfdocument>
Expected Result
It should work as how it is working in Browser, screen shot attached.

Selenium IDE: Why clickAt does not work here?

Apparently Selenium IDE is fairly unreliable. For example, the last command in the following script does not have any effect inside the script but if I double click on it separately it opens the file selection dialog. Why?
Another question, how do I provide file selection with a next command?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.gumtree.com/" />
<title>gumtree</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">gumtree</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>https://my.gumtree.com/postad</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//form[#id='frmSyi']/div/div/div/div/nav/ul/li[2]/div/span[2]</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//form[#id='frmSyi']/div/div/div/div/div/div/div/div/ul/li[10]/span</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//form[#id='frmSyi']/div/div/div/div/div/div[2]/div/div/ul/li[2]/span</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//form[#id='frmSyi']/div/div/div/div/div/div[3]/div/div/ul/li[4]/span</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=continueButton</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>link=Add image</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
ClickAt is a specialised command for clicking coordinates. So you are using it in a wrong way. You should use regular click, or doubleClick or (in a very special case) clickAt with providing coordinates string.
File uploading is not so straight-forward. You should find an input that contains file name for uploading. Send a file-name to it with type command or javascript. And finally initiate uploading. Like:
type | id=hiddenInputForFileName | /path_to_your_file/your_file.lol
click | id=startUploadingButton
That's an example. Your code will depend on the file uploading form design. I hope it will help. If it won't please provide the html of your page and I will post the code for your situation.

Make a loop to write the contents of some variables in Selenium

I'm using the Selenium IDE to store the values of a table in a page in some variables and then type the text in those variables in a text box, one per line.
The problem is that when I loop through the variable ${card} the contents of the variable replace themselves while they should be one at a line.
I would also like to know if I'm using the right tool for doing this. Should I be using the Selenium Webdriver or something else?
Here is the code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://es.magiccardmarket.eu/" />
<title>test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>https://eu.magiccardmarket.eu/?mainPage=browseUserProducts&idCategory=1&idUser=13786</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>x</td>
</tr>
<tr>
<td>label</td>
<td>target1</td>
<td></td>
</tr>
<tr>
<td>storeTable</td>
<td>//div[#id='siteContents']/div[2]/div[2]/div/form/table.${x}.2</td>
<td>card${x}</td>
</tr>
<tr>
<td>storeEval</td>
<td>new Number(${x}) + 1</td>
<td>x</td>
</tr>
<tr>
<td>gotoIf</td>
<td>storedVars['x'] < 31</td>
<td>target1</td>
</tr>
<tr>
<td>open</td>
<td>http://www.quackit.com/html/codes/html_text_box_code.cfm</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>x</td>
</tr>
<tr>
<td>label</td>
<td>target2</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>storedVars['card' + storedVars['x']]</td>
<td>card</td>
</tr>
<tr>
<td>type</td>
<td>name=comments</td>
<td>${card}<br /></td>
</tr>
<tr>
<td>storeEval</td>
<td>new Number(${x}) + 1</td>
<td>x</td>
</tr>
<tr>
<td>gotoIf</td>
<td>storedVars['x'] < 31</td>
<td>target2</td>
</tr>
</tbody></table>
</body>
</html>
Type sets the value of an input field. So each time you call type it's only setting it to the 3rd column.
Something like this:
<tr>
<td>storeValue</td>
<td>name=comments</td>
<td>com</td>
</tr>
<tr>
<td>type</td>
<td>name=comments</td>
<td>${com}\n${newvalue}</td>
</tr>
Or you can build up the var and use the type command once.
Frankly I would do this looping in javascript rather than use flow control, which I don't like.