RML dotted line for a cell - rml

I need to know if exists some style like #lineBelowThicknes="1"# that allows me to have a line below the text that I wrote, but with points, example:
<blockTable style="default">
<tr>
<td lineBelowThickness="1">
<para>
Some text here above the line of the cell
</para>
</td>
</tr>
</blockTable>
but instead:
lineBelowThickness="1" that gives me ______________________
I want this kind of line: ..........................................

It can be done but not as a property of the cell, The line it needs to be draw. Here there are some useful information about RML https://www.reportlab.com/docs/rml2pdf-userguide.pdf and more precisely (as an example):
<lineMode width="2" dash="5,5,2,10"/>
<lines>5.5in 4.5in 6.5in 4.5in
6.5in 4.5in 6in 4in
6in 4in 6in 4.75in
</lines>
<drawCentredString x="6 in" y="3.75 in">
width=2, dash=5,5,2,10
</drawCentredString>

Related

How to find element using xpath when dom changes with window size

The DOM my test application changes depending upon the window size. So I am trying to write an XPATH which will cater for both of these scenarios.
Scenario 1: When the window is maximum size below is the dom:
<tbody>
<tr><td class="sv-table-col-xs"><img src="image.gif">
</td>
<td>03/Mar/2020</td>
<td><span class="sv-label sv-label-primary">You</span>
</td><td>0% of 1</td>
<td>Complete academic review</td>
</tr>
</tbody>
I am using xpath:
//tr[td[contains(text(), '03/Mar/2020')]]//a[text()='Complete academic review']
This works fine and finds the element.
Scenario 2: Below is the DOM when window is shrinked
<tbody>
<tr><td class="sv-table-col-xs">
<b class="tablesaw-cell-label">Status</b>
<span class="tablesaw-cell-content"><img src="../images/emailunr.jpg" style="border:0px" alt="..\images\icons\exploding_email1.gif.gif"></span>
</td>
<td><b class="tablesaw-cell-label">Due Date</b>
<span class="tablesaw-cell-content">03/Mar/2020</span>
</td>
<td><b class="tablesaw-cell-label">Primary Reviewer</b>
<span class="tablesaw-cell-content"><span class="sv-label sv-label-primary">You</span></span>
</td>
<td class="tablesaw-cell-hidden"><b class="tablesaw-cell-label">Other Reviewers</b>
<span class="tablesaw-cell-content">0% of 1</span>
</td>
<td class="tablesaw-cell-hidden"><b class="tablesaw-cell-label">Action</b><span class="tablesaw-cell-content">
Complete academic review
</span></td></tr>
</tbody>
For this the xpath changes to:
//tr/td[5]/span/a
to get to both elements I have tried to use:
//tr/td[5]/span/a | //tr[td[contains(text(), '03/Mar/2020')]]//a[text()='Complete academic review']
this xpath works but I on shrinked window I am not validating the element with text contains ''03/Mar/2020' & 'Complete academic review'.
Not sure if there is a way to validate the texts in both scenarios before selecting the element.
You want to use string value of a node. And function text() doesn't do it.
So instead use . or string() at least for date filtering part.
//tr[td[contains(., '03/Mar/2020')]]//a[text()='Complete academic review']

Web Automation - How do I input text into a rich text box on a website (textarea) defined by a class?

I have been trying this for a few days and am completely stuck. If anybody could help me out I would be very grateful; Im using VB.NET.
The HTML Code:
<tbody>
<tr>
<td class="chat-attachment-cell"></td>
<td class="chat-input-cell">
<textarea class="chat-message-input"></textarea>
</td>
<td class="chat-send-cell"><a href="#" class="chat-send-button"> alt="Send" width="66" height="66" border="0">
</a>
</td>
</tr>
</tbody>
The text box I need to input into is this bit
<textarea class="chat-message-input"></textarea>
Thankyou in advance for any help provided
You select the element then change the .innertext property with what you want.
There are multiple ways to do it, and I can't give you an example because I don't know what you are using nor the whole html, but for example it could look like this:
WebBrowser1.Document.GetElementById("someid").InnerText="Sometext"
For start, you can try looking how the collection of elements you get looks, then you should be able to figure out what to do next.
Dim test = WebBrowser1.Document.GetElementsByTagName("textarea")
For example on this page:
Dim test = WebBrowser1.Document.GetElementsByTagName("tbody")
test(1).InnerText = "Hi there"

IE Automation - Excel VBA

I am trying to do IE Automation through Excel VBA code.
I have a web page which has Top, Middle and results forms. I need to input values in the Middle form but unable to get any controls from this and get it as 0. Ie.Document.forms.Length gives 0. Tried the below code as well but does not work.
Ie.Document.forms("SearchForm").elements("PolicyNumber").Value = "Josh"
Looks like this form is on a frame but don't see frame reference inthe HTML code. HTML code is as below:
<body bgcolor="white">
<form method=POST name="SearchForm" action="PolicySearch" target="resultframe" >
<input type=hidden name="NewSearch" value="True" ></input>
<table class=box2 cellpadding="1" cellspacing="0" border="0" width="760" align="top" halign="left">
<tr>
<td class="name" align="left">
Policy# :<input type=text name="PolicyNumber" maxlength="10" value="" size="10"></input>
</td>
try thing as
Ie.Document.getElementsByName("PolicyNumber").Item(0).Value="Josh"
or
Iie.Document.getElementsByName("PolicyNumber").Value="Josh"
Try this:
declare a new variable:
Dim Elements As IHTMLElementCollection
Set the elements with the form and tag name, eg. input
Set Elements = IE.Document.forms("SearchForm").Document.getElementsByTagName("input")
Pass the value to the text / input
Elements("PolicyNumber").Value = "Josh"
Note: the code above is originally for frames and need to add MS HTML Objects library in the references. Though you can use Elements by declaring as object, declaring as IHTMLElementCollection will have events when you press "."

Element is no longer attached to the Dom error for link

I try to get a href from an anchor according to linkText given with func param (for example here Westwood or Linda).
In the code below I changed classes values (cause of company info), but beside thats the code. For each <tr> the hrefs are identical for both <td>, but different from <tr> to <tr>
I get the 1st href with:
driver.findElemnt(By.xpath("//a[#class = 'class Name of a']").getAttribute("href")
or the same with:
xpath="//a[#class = 'class Name of a'][1]";
but when I go:
"//a[#class = 'class Name of a'][2]" or 3 or 4...
or when I use:
By.partialLinkText
It fails, so I never get beyond the 1st <td> of the first <tr>.
The Error: oopenqa.selenium.StaleElementReferenceException : Element
is no longer attached to the Dom.
The Elements are visible all the time, so its not a visibility problem.
This is the html:
<tr class="Class name for tr here">
<td headers="description _ CustomerList:lastName">
Westwood
</td>
<td headers="description _CustomerList:firstName">
Linda
</td>
</tr>
You're trying to retrieve the second anchor tag within the same parent (in the example document: table cells).
Instead of
//a[#class = 'class Name of a'][2]
query the second anchor tag in the whole document:
(//a[#class = 'class Name of a'])[2]
Some more examples how to use positional predicates (I omitted the class predicate here):
Anchor tags from all second table cells per row:
//td[2]/a
Second anchor tag per row:
//tr//a[2]

Use Greasemonkey to remove table

I am trying to replace a table with my own table using grease monkey. The page that has the table has 2 tables with the same class and no IDs.
I need to replace only the second table (with my own table) and do nothing to the first table. There is nothing that really makes the second table unique from the first table, so the only thing I can think of is trying to add a DIV around the second table, but cant figure it out.
Any ideas? Heres the page code:
<h3>Table 1</h3>
<table class="details" border="1" cellpadding="0" cellspacing="0">
<tbody><tr>
<th>1</th>
<td>2</td>
</tr>
</tbody></table>
<h3>Table 2</h3>
<table class="details" border="1">
<tbody><tr>
<th>1</th>
<td>2</td>
</tr><tr>
<th>3</th>
<td>4</td>
</tr>
</tbody></table>
You can use xpath to find the second tables, and do something with it. The xpath expression would be (//table[#class="details"])[2]. Below I added an example which uses (//pre)[1] instead, this will find the first code block on this page, I will hide it as an example. So this hides the page code from your question. (//pre)[2] will hide my script.
See Also here for a tutorial how to use xpath.
// ==UserScript==
// #name so-test
// #namespace test
// #include http://stackoverflow.com/questions/4635696/use-greasemonkey-to-remove-table
// ==/UserScript==
// find first <pre> on this page
var xpathResult = document.evaluate('(//pre)[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
var node=xpathResult.singleNodeValue;
// now hide it :)
node.style.display='none';