I have the following XPATH selection.
//BLOCKQUOTE[#class='postcontent restore ']/A
Now i want to exclude certain links using wildcard.
Where attribute #href!="http://domain.com/download.php *'
How do I this ?
Use:
//BLOCKQUOTE[#class='postcontent restore ']
/A[#href = 'http://domain.com/download.php']
This selects any A element in the XML document, whose href attribute is 'http://domain.com/download.php' and that is a child of any BLOCKQUOTE element in the XML document, whose class attribute has string value 'postcontent restore '
If you want the selected links to have any URL pointing to that domain, use:
//BLOCKQUOTE[#class='postcontent restore ']
/A[starts-with(#href, 'http://domain.com/download.php')]
Update: In a comment the OP clarified:
I want to exclude... anything starting with that link/url
Use:
//BLOCKQUOTE[#class='postcontent restore ']
/A[not(starts-with(#href, 'http://domain.com/download.php'))]
Related
we want to automate an web application with Robot framework/SeleniumLibrary. The app contains some tables, which do not have simple unique identifiers like id/name/class... They only can be uniquely identified via a nested property. Here a sample excerpt of the properties window (DevTools)
grid: window.<computed>
> FormSubmitOnlyChanged : true
> ...
> _dataprocessor: dataProcessor
> autoUpdate: false
> ...
> serverProcessor: "/TEST/GridNew/multi?group=getMetaData&name=Sources&editing=true"
> ...
> ...
...
The Element looks as following:
* The id parameter contains an dynamic id and can therefore not be used for object identification.
We tried some approaches, e.g.
//div[contains(#grid._dataprocessor.serverProcessor, 'group=getMetaData&name=Sources')]
or
//div[contains(#serverProcessor, 'group=getMetaData&name=Sources')]
but none of them did work. Does anybody have an idea how to get an XPath that makes it possible to contain the nested property? Thank you in advance.
Please try this XPath:
"//div[contains(., 'group=getMetaData&name=Sources')]"
The dot . means here any attribute containing group=getMetaData&name=Sources value.
Also, I see the parent element in the shared picture is hidden. Maybe this causes your problems?
Please try this below xpath:
//div[starts-with(#id,'cgrid2_')]
The developers now managed it to set an id manually to overwrite the generated dynamic ID. Furthermore, after more research, it seems to be not possible to use this property for XPath.
I have the following XML:
<envelope>
<action>INSERT</action>
<auditId>123</auditId>
<payload class="vendor">
<fizz buzz="3"/>
</payload>
</envelope>
I am trying to write an XPath expression that will pluck out vendor (value for the payload's class attribute) or whatever its value is.
My best attempts are:
/dataEnvelope/payload[#class="vendor"]#class
But this requires the expression to already know that vendor is the value of the attribute. But if the XML is:
<dataEnvelope>
<action>INSERT</action>
<auditId>123</auditId>
<payload class="foobar">
<fizz buzz="3"/>
</payload>
</dataEnvelope>
Then I want the expression to pluck out the foobar. Any ideas where I'm going awry?
If you need #class value from payload node, you can use
/dataEnvelope/payload[#class]/#class
or just
/dataEnvelope/payload/#class
At first, your two XML files are out-of-sync - one references envelope and the other references dataEnvelope. So exchange one for the other, if necessary.
So, to get the attribute value of payload, you can use an XPath expression like this which uses a child's attribute value to be more specific:
/envelope/payload[fizz[#buzz='3']]/#class
Output is:
vendor
If the document element can/will change, then you can keep the XPath more generic and select the value of the class attribute from the payload element that is a child of any element:
/*/payload/#class
If you know that it will always be a child of envelope, then this would be more specific(but the above would still work):
/envelope/payload/#class
In order to find all attributes with name myAttr in the document I can do this //#myAttr but what if I want to specify the root and still find all attributes with that name in the document? Something like /root/{whatever_or_nothing}/#myAttribute
How about this way :
/root//#myAttribute
I have my tag ${file.name} in a jsp file to display a name of file to download
name containt a full file name,include file extension. for example
testfile.png
a-file.zip
testfile-test505454654.png
a-filenum5468.docx
other_file_with_a_name_very_very_very_larrrrrrrrrrrrrrrrrrrrrge.pdf
Files with very long names, crash my layout.
I think the way to format the file name to shorten it but include the extention. Maybe
testfile.png
a-file.zip
testfile-test505454....png *
a-filenum5468.docx
other_file_with_a_na....pdf *
How I can do?
in href no problem because it is done by id ${file.id}
If file is a POJO, you may add a getter-method to the POJO (something like String getShortName(){}) that returns a short version of the file name. And then use the method in your EL expression: ${file.shortName}.
I would write and register a custom tag that would take care of shortening the output to a maximum length
<custom:short value="${file.name}" var="shortFileName" />
The tag would take care of shortening based on defaults or values you specify in the element and putting it the result in a request attribute you can use anywhere after that declaration.
Since the requirements can be used many times so You should go with CUSTOM Tag solution like #Sotirios Delimanolis suggested.
JSTL function ( Like c:fn ) is another solution. Using jstl function get better performance than Custom tag ( simple / classic model )
Link: http://www.noppanit.com/how-to-create-a-custom-function-for-jstl/
I create a new profile document with the following code:
Set doc = db.Createdocument()
doc.Form = "SMBPrivateProfile"
Call doc.Computewithform(True,True)
Call doc.Save(True, False)
But whenever I want to read a field by #GetProfileField i get an empty string, even if the field I want to read has a default value.
After opening & saving the document manually everything works.
Further details:
I improved an application and hit Application --> Replace Design.... The new version includes a new field within the profile document. When reading one of these new fields, the result is an empty string. When reading an 'old' field within the same document the result is the expected string.
e.g.:
MessageBox([OK];"Title"; #GetProfileField("SMBPrivateProfile"; "OLD_FIELD"; #ThisName))
--> Will result in: "This is a fancy old default value"
MessageBox([OK];"Title"; #GetProfileField("SMBPrivateProfile"; "NEW_FIELD"; #ThisName))
--> Will result in: "" (instead of "This is a fancy new default value")
That's not a profile document. To create profile document use:
db.GetProfileDocument("SMBPrivateProfile");
You can also add a second parameter for a unique key in addition to profile name.
Also consider if you really want to use profile documents. They are heavily cached and not visible in any views.
If I'm reading you right, it appears that you have updated a form and added a new field with a default value formula. You are then reading an existing document. When you do this, the new field that you added to the form does not yet exist. New fields and formulas aren't applied to existing documents until you do something to force them to be applied.
If it's a regular document (as your original code indicated), you can just open the document in the Notes client, edit, and re-save it. That will create the NEW_FIELD and give it its value. If there are lots of these documents, you could write a simple formula agent to do this via #Command([ToolsRefreshAllDocs]) or #Command( [ToolsRefreshSelectedDocs]).
If it is a profile document (as per the responce chain to #Panu's anser), then after you do the replace design you will have to write an agent to open the existing profile document using db.getProfileDocument use doc.ReplaceItemValue("NEW_FIELD";"new value").