How to find 1st alphabet of a link - selenium

My XPath is Computer Science and Creativity. In Selenium IDE how can I locate the 1st alphabet in Computer? Thanks

In selenium IDE you can use JavaScript to extract 1st alphabet in a link text. Here are the steps for this:
Store the entire link text using storeText command. For example, this question's link text "How to find 1st alphabet of a link"
<tr>
<td>storeText</td>
<td>css=a.question-hyperlink</td>
<td>ftext</td>
</tr>
Then use storeEval command and a JavaScript to extract 1st char of a link text - in this example, it will extract 1st char "H" and stores it in variable firstAlpha
<tr>
<td>storeEval</td>
<td>storedVars['ftext'].charAt(0)</td>
<td>firstAlpha</td>
</tr>
Now you can use this variable that containing 1st char of a link text in another step/command, here I am just printing in log.
<tr>
<td>echo</td>
<td>${firstAlpha}</td>
<td></td>
</tr>

Related

Remove base64 value from string column in Postgres

I have a text column in a table that contains HTML data along with image represented in base64 encoding.
Here is an example:
</p><p><span lang="EN"> </span></p><p>
</p><p><img width="263" height="135" align="right" src="data:image/png;base64,/9j/4AAQSkZJRgABAQEAYABgAA...." alt=""></p>
The string after base64 is really long. I want to remove the long string representation and replace with the word "image".
I tried a pattern match on base64, and remove everything after that until " mark before the alt keyword. It worked on cases where there is only occurrence of a base64 value. When there are multiple occurrences, it fails.
Is there a better way to approach this problem in order to remove just the string representing image in base64 encoding?
To have the actual replacement work more than just once, you need to use the "global" flag for the regexp_replace, e.g.:
=# SELECT regexp_replace(E'\n\n...height="135" align="right" src="data:image/png;base64,/9j/4AAQSkZJRgABAQEAYABgAA...." alt="" ...\n<p></p>\n<p><img align="left" src="data:image/png;base64,/9j/4AAQSkZJRgABAQEAYABgAA...." class="test" alt=""/>\n', '(data:[^,]+,)[^"]+', '\1<data>', 'g');
regexp_replace
------------------------------------------------------------------------------
+
+
...height="135" align="right" src="data:image/png;base64,<data>" alt="" ... +
<p></p> +
<p><img align="left" src="data:image/png;base64,<data>" class="test" alt=""/>+
(1 row)
...so: regexp_replace(my_html_column, '(data:[^,]+,)[^"]+', '\1<data>', 'g')
That should match and replace all data URI's of the given text.
Maybe your problem id the greedy match, and the solution is to match anything but " characters:
regexp_replace(col, 'base64,[^"]*', 'image')

Find and update a numbering in a html file with awk

I am trying to update a numbering/numeration in a test.html file:
<td class="no">(8)</td>
<td class="no">(9)</td>
<td class="no">(10)</td>
<td class="no">(11)</td>
<td class="no">(23)</td>
A new line could be added between the other lines, so I don't want to update the numeration always manually. Another condition is, that the update should start after number 7.
I tried to use gensub by replacing the line by the match but it doesn't work how I thought. There must be an easier way to determine the numbers! No tutorials or forum posts did help me or I didn't understand them...
So far what I have:
/^<td class="no">\([0-9]+\)<\/td>$/ {
a = gensub(/(.*)([0-9]+)(.*)/, "\\2", "g") # this finds only 1 digit, why?
if (a > 7) print a
}
If you only need to determine the numbers, you only must get rid of any character not being a digit
/^<td class="no">\([0-9]+\)<\/td>$/ {
gsub("[^0-9]","")
if ((0+$0) > 7) print
}
update: (0+$0) > 7 replaces my original $0 > 7 because the cygwing gawk does not compare $0 and 7 as numerical values but as string values --- I do not know why. I'm not familiar with cygwin.
This solution prints the following output:
8
9
10
11
23
If the test.html file had contained a line like
<td class="no">(71)</td>
the original code ($0 > 7) would have also print
71
in cygwin.

How do you add a numbered or bulleted list in a table cell entry or line breaks

Docbook 5 trying to add a simplelist or single lines of text in a table row cell entry but cannot find the secret combination of allowed elements. Is it possible?
This is valid according to my editor:
<informaltable>
<tgroup cols="1">
<tbody>
<row>
<entry>
<para>A single line of text</para>
<simplelist>
<member>Apiary</member>
<member>Beekeeper</member>
</simplelist>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>

Aligning images in doxygen

I am writing a doc file in doxygen, and I included an image by doing
\image html screenshots/enabled.png "caption"
This shows my enabled.png image on the generated documentation. However, I would like the image to be aligned to the left (since the rest of the documentation is that way). Is there any way to do this in doxygen without doing it with inline html or css?
Using the following HTML syntax works on Doxygen 1.8.6 (tested with Firefox 66):
/*! \mainpage Test
*
* <img src="my-image.jpg" align="left">
* <div style="clear: both"></div>
*
* This is a test page.
*
*/
Doxygen wraps the image in a <div class="image">, but the align property overrides centering. The extra clearance <div> is added to avoid having the following text written to the right of the image.
<img src="myimage.png" align="left"/>
But you may need to add \n chars afterwards to prevent text wrapping to the right of the image.
html only as well
Stuffing the image into an aligned Markdown table seems to work:
| Image description |
| :---- |
| \image html image.png |

How to handle new line in handlebar.js

I am using HandleBar.js in my rails jquery mobile application.
I have a json returned value data= "hi\n\n\n\n\nb\n\n\n\nhow r u"
which when used in .hbs file as {{data}} showing me as hi how r u and not as with the actual new line inserted
Please suggest me.
Pre tag helps me
Handlebars doesn't mess with newlines in your data unless you have registered a helper which is doing something with them. A good way of dealing with newlines in HTML without converting them to br tags would be to use the CSS property white-space while rendering the handlebars template in HTML. You can set its value to pre-line.
Read the related documentation on MDN
Look at the source of the generated file - your newline characters are probably there, HTML simply does not render newline characters as new lines.
You can insert a linebreak with <br />
However, it looks like you're trying to format the position of your lines using newline characters, which technically should be done by wrapping your lines in <p> or <div> tags and styling with CSS.
Simply use the CSS property white-space and set the value as pre-line
For a example:
<p style="white-space: pre-line">
{{text}}
</p>