I have a UI5 table, but would like to have an input element that span multiply rows under the other text. Something like the table below.
<table>
<tr><td>v1</td><td> v2</td><td> v3</td></tr><br>
<tr><td >input text </td></tr>
</table>
Unfortunately, you'll have to find another approach. The sap.m.Table type does not currently support this, as there are no span type of properties on the sap.m.Column type.
Ok. Learned that it is not possible at the moment.
So I'm just going to use a textarea at the end of the line. I think it may look okay.
Did you mean row span like here or column span like here
For rowspan there is existing sap.m.Column attribute mergeDuplicates you may want to check.
Related
I need to verify that a <tr> exists which contains 3 <td> with specific values.
There are 100+ <tr> tags on the page. I am trying to filter them using 1 xpath.
for instance if I filter all the <tr> on these 3 values:
//td[contains(text(),'Belgium')]
//td[contains(text(),'be-stelara-cd-uc')]
//td[contains(text(),'2022-07')]
That should return 1 <tr> containing those <td>.
So what I need to do, would be to filter each xpath against the previous leaving a single unique remaining. I came across the | union operator which is almost what I want but instead of combining the results I want to exclude them.
I tried this xpath:
//tr[contains(td/text(), 'Belgium') and contains(td/text(), 'be-stelara-cd-uc') and contains(td/text(), '2022-07')]
html example:
https://prnt.sc/qcmEu0zSvu3S
Edit:
//tr[contains(td/text(), 'Belgium') and contains(td[2]/text(), 'be-stelara-cd-uc') and contains(td[3]/text(), '2022-07')]
This works, I did not realise that the td would check for ordering as well. If possible I would like to tweak the question to come up with a universal solution considering that the order cannot be guaranteed.
If you can rely on the data in the picture, that is: no whitespace and no other inline-elements more than shown, you could try this:
//tr[td[text()= 'Belgium'] and td[text()= 'be-stelara-cd-uc'] and td[contains(text(), '2022-07')]]
If you want to be extra sure and want to filter unwanted space you could try this:
//tr[td[text()[normalize-space()= 'Belgium']] and td[text()[normalize-space()= 'be-stelara-cd-uc']] and td[contains(text(), '2022-07')]]
If more content can be present just use the . and contains() together like this:
//tr[td[contains(., 'Belgium')]and td[contains(., 'be-stelara-cd-uc')]and td[contains(., '2022-07')]]
And to be complete you could also just test the text-content of the tr like this:
//tr[contains(., 'Belgium') and contains(., 'be-stelara-cd-uc') and contains(., '2022-07')]
Use any of the below xpath to identify the tr
//tr[.//td[contains(., 'Belgium')]][.//td[contains(., 'be-stelara-cd-uc')]][.//td[contains(., '2022-07')]]
OR
//tr[contains(., 'Belgium') and contains(., 'be-stelara-cd-uc') and contains(., '2022-07')]
I am trying to find an unique xpath for the below element, please advice if there are any better xpaths to make it for general text as I have currently given for that specific name.
<td tabindex="4" style="text-align: left;" title="name" class="">Name</td>
xpath i am using: //td[#title='name']
here if the name is changed with something else in the code, this wouldn't work, could someone help me identify unique xpath which works in general for any text. Thanks!
You can concatenate (using and / or) multiple attributes of element to find the element precisely .
By.xpath("//td[#title= 'name' and contains(text(), 'Name')]")
However we need to see more details of the code and your DOM of page to find element.
There will always be some element which will never change in the page(like name of table) using that as a relative point ,we can refer to the row of the table.
the simplest way to find the XPath of any element is to go to the developer options and select the markup of the element you want XPath of.
Right Click -> Copy -> XPath
I believe this is the simplest way. And you will also where you are doing wrong.
Screenshot attached for your reference.
I have used the general syntax - "//td[text()='{}']" and passing the name parameter when i define a method so that it won't be specific to one and others can test using the same locator with their name changed when someone else uses the testcase.
Thanks everyone for your response!
I have a table of number inputs for different products. Each row looks like this:
<tr>
<td><input type="number" name=quantity1 value="0"></td>
</tr>
At the bottom, I'd like to show a sum of quantities based on what the user inputs on each row. All html code is server rendered and I only use Vue for the interactive part, so I'm not using v-for to generate the list on the client.
My question is: Is there a way to annotate the server template (or another technique) so that I can easily reference the input value of each row with Vue (aside from something like vanilla querySelector)? I imagine there must be something more in the lines of v-model that would perhaps collect all values in a data array or similar. Thanks!
I has a page as follow:
<table>
<tr>
<th>Company Name</th>
</tr>
<tr>
<td> What Ever Company</td>
</tr>
</table>
The company name is placed arbitrary in the table, so I can only use the link's text to locate the link:
selenium.click("link='What Ever Company'");
However, it says: ERROR:Element link='What Ever Company' not found.
What is the problem here? Is there any other way to click on the link?
Many thanks.
EDIT
Seem that the problem is I have several links with the same text (my bad). After making the link's text unique, I use selenium.click("//a[contains(text(),'Test Campaign 1756237989')]") and it works.
Could this be because you're forgetting the space at the start of the link?
selenium.click("link=' What Ever Company'");
^
Another possible way of clicking the link, is to use an XPath expression:
selenium.click("//a[contains(.,'What Ever Company')]");
This will match all links with 'What Ever Company' in it.
If you want it more exact:
selenium.click("//a[.=' What Ever Company']");
This will only match if the anchor equals ' What Ever Company'.
Another option is to make the search more specific (i.e. tell the locator this link is always inside a <td> with an <a> inside):
selenium.click("//td[a]/a[contains(.,'What Ever Company')]");
The //td[a] looks for all <td> elements with <a> inside. (Differs from //td/a in that if you look for elements with //td[a][2] you get the second <a> which is inside a <td>, while //td/a[2] on the other hand gets the second <a> of the first <td>.)
EDIT: I thought using . as a reference to text() in the XPath expressions should work, but if it doesn't, try using text() instead.
Try these XPaths:
"//table/tr[2]/td/a"
or
"//a[contains(text(), 'What Ever Company')]"
Should work.
I'm using Struts2 iterator to setup a list of checkbox in a table. I want to have 10 checkbox per row, so I'm doing the following:
<table>
<tr>
<s:iterator value="securityMasterFields" status="fieldNameStatus" var="fieldName">
<s:if test="#fieldNameStatus.index % 10 ==0">
</tr><tr>
</s:if>
<td>
<s:checkbox name="fieldsToShow" fieldValue="%{fieldName}" value="%{fieldName}"/>
</td>
</s:iterator>
</tr>
</table>
It never goes through the if, so I'm assuming the mod is not been calculated correctly. How do I do it?
thanks
Well, I had to add some parentheses and it worked correctly. The loop was working, it was just that it wasn't going through the if.
<s:if test="(#fieldNameStatus.index % 8 )==0"></tr><tr></s:if>
It looks good to me. Two thoughts:
1) try printing the result of the test in s:property tag
2) It looks like you will have empty table rows... Are you looking at the generated html or just the output, because if it is just the output then unless you have some CSS giving you some table padding and borders, without an empty 'td' element the row might collapse and make it appear as if nothing is being added. So do make sure you print the empty 'td' elements too!