How to find xpath by element text in selenium ide in order to use the element? - selenium-ide

Table contains columns with headers like those
vehicle no | driver
103 | John
the xpath location is:
//tr[3]/td[4] | //tr[3]/td[5]
The columns can be customized and then xpath will change therefore, is there a way to automatically find the xpath location of the columns by contained text ?
For now i'm using loop with scanning all of the headers, maybe there is more efficient way?

Try this for exact search:
//td[text()='EXACT']
Or for partial search:
//td[contains(text(),'PARTIAL')]
This gives you two options in xpath to patch for text.

Am assuming that your table would look some thing like below..
<table>
<th> <td> vehicle no</td> <td> driver</td></th>
<tr> <td> 103</td> <td> John</td></tr>
</table>
To create xpath location of the column, by contained text ? You can use 'contains' in xpath..
XPATH1 = //table//td[contains(.,'John')]
XPATH2 = //table//td[text()='John']
Please let me know if the above does not solve your problem.

Maybe this helps?
if you want to get 'John':
in the command field put: [verify text]
in the target field put: xpath=//table//td[contains(.,'driver')]/following::tr/td[2]
in the value field put: John

Related

DOM element not rendering html

I have built an html table that generates dynamically from a data array. It is intended to make a menu of beers on tap in my bar. The array contains the following data: [tap_number, brewery_image, beer_name, price_for_a_pint, price_for_a_pitcher]. Therefore the array dictates that the table generate with 5 columns and 14 rows (with current data). The image data consists of an html tagged image and similarly the beer_name is tagged <h3></h3>. All the html tagged data is rendering as text. What have I done wrong? btw, using Materialize css for basic table styling. Have tried with bootstrap also - same result. Here's a snippet of the html element that the js generates:
<table class = "tabel">
<thead>
<tr>
...has <td>column name</td> X5
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><img src='[url of image]' alt=''></td>
<td><h3>[Beer_Name]</h3></td>
<td>$6</td>
<td>$10</td>
</tr>
...a bunch more rows..
</tbody>
</table>
.
So data positions 1 and 2 should be rendering according to html tag but are just appearing on the page as the text of their html. All data from the array is passed as textContent. Should I be using innerHtml? when I do, nothing at all renders. Cannot figure out what amateur mistake I've made or whether Materialize is screwing me... Thanks for any advice...
It was an amateur mistake. was using innerHtml instead of innerHTML....

Inject <thead> default with table in tinymce

I'm using Umbraco as the CMS, 7.6 - Umbraco.TinyMCEv3
So using insert Table will create HTML something like following
<table>
<tbody>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
How can I configure to add default <thead> when table is created
<table>
<thead>
<tr>…</tr>
</thead>
<tbody>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
Thanks
I don't know if this is all that possible; it seems as though that functionality isn't included as a setting within the editor.
The obvious thing to do if the setting isn't included is to create it yourself - the way to to do this would be to either extend the existing editor or copy and paste the editor to a new one locally.
The files for the editor are under \Umbraco\lib\tinymce
Unfortunately, it appears the angular js file associated with this editor is only available as a non-human readable minified version - likely owing to the fact that tinymce is under license. So any modification of this would be quite tricky, to say the least.
Perhaps see if there is another way around this? You can always set css to select the first child row of the table if it is for styling purposes. Otherwise the only other option would be to create your table in the editor, then choose the code edit option to manually insert the correct table structure.
I have v5 with vue.js
After created table:
1-Click right on row of head you want > row > row properties
click right on row of head>row>row properties
2-In general choose "Header" at Row type
in general select of "Header" at Row type

xPath Groupings how?

OK So, I'm learning/using xpath for a basic application that's effectively ripping data off another website.
I need to gain the knowledge of each persons Country/Suburb/area.
In some instances you can get Australia/Victoria/Melbourne for instance.
Others may just be Australia/Melbourne.
Or even just Melbourne OR just Australia.
So I'm current able to view the below code and rip all of the information with the string xpath //table/tr/td/table/tr/td/font/a. This returns every entry, but what I really want is to group each lot separately.
I hope someone out there on planet earth knows what I just tried to explain... and can help...
Good day!
The source document contains data like this:
<tr>
<td>
<font face="arial" size="2">
<strong>Location:</strong>
Australia,
<a href='http://maps.google.com/maps?q=Australia%20Victoria'target="mapblast" style='text-decoration:none'>Victoria</a>,
<a href='http://maps.google.com/maps?q=Australia%20Melbourne%20Victoria'target="mapblast" style='text-decoration:none'>Melbourne</a>
</font>
</td>
</tr>
To find each person's record, the XPath query is //table/tr/td/table/tr/td/font, or you could use //td/font[strong = 'Location:']. This will return a collection containing 1 element for each person.
To find the a elements under a particular font you could use XPath a from the font. This can also be done by iterating the children collection of the element.

Can I append an Ajax requestXML object to my document tree all in one go?

Greetings.
Here is an XML object returned by my server in the responseXML object:
<tableRoot>
<table>
<caption>howdy!</caption>
<tr>
<td>hello</td>
<td>world</td>
</tr>
<tr>
<td>another</td>
<td>line</td>
</tr>
</table>
Now I attach this fragment to my document tree like so:
getElementById('entryPoint').appendChild(responseXML.firstChild.firstChild);
But instead of being rendered as a table, I get the following text:
howdy! helloworldanotherline
The same result occurs of I replace firstChild.firstChild with just firstChild.
It seems like I'm just getting the nodeValues, and all of the tags are stripped out?!
Am I fundamentally misunderstanding what the responseXML object is supposed to represent?
This works, BTW, if I take out the 'root' tags, and set innerHTML to responseText.
Can someone please enlighten me on the correct way to use responseXML?
You get the text instead of a table, because you use pure DOM for manipulations and your response XML doesn't have the namespaces declarations. So when appending an XML element browser doesn't know whether your "table" tag is from HTML, XUL, SVG or else from.
1) Add namespace declaration:
<table xmlns="http://www.w3.org/1999/xhtml">
2) Instead of directly inserting a reffered XML DOM Element, you should first import that node into your HTML DOM Document:
var element = document.importNode(responseXML.firstChild.firstChild, true);
document.getElementById('entryPoint').appendChild(element);
Hope this helps!
You can create an element at the position you want to insert and than do
element.innerHTML = request.responseText

php - splitting a string with HTML by the first instance of a table cell

I am checking on HTML content on my page, and I've got the split down to have the variable left with this content:
">
<td>Oklahoma City</td>
<td>Oklahoma</td>
<td>OK</td>
<td>405</td>
<td>CST</td>
</tr>
</table>
<div id="
Those are dynamic pages I'm checking, so the data will always be different, but the layout the same...
How can I get the value out of the second <td> if that html is in 1 variable(string)?
It was a full page, I've used explode twice to remove everything above a div field and everything below the last dive field id... so it has some open html tags left because I did not know how to get rid of that along the way to be left with just this:
<td>Oklahoma City</td>
<td>Oklahoma</td>
<td>OK</td>
<td>405</td>
<td>CST</td>
</tr>
</table>
Can you tell me how to get that out? I just need the second one because it is the county and that is what I'm checking on...