How to use "not" in XPath? - dom

I want to write something of the sort:
//a[not contains(#id, 'xx')]
(meaning all the links that there 'id' attribute doesn't contain the string 'xx')
I can't find the right syntax.

not() is a function in XPath (as opposed to an operator), so
//a[not(contains(#id, 'xx'))]

you can use not(expression) function
or
expression != true()

None of these answers worked for me for python. I solved by this
a[not(#id='XX')]
Also you can use or condition in your xpath by | operator. Such as
a[not(#id='XX')]|a[not(#class='YY')]
Sometimes we want element which has no class. So you can do like
a[not(#class)]

Use boolean function like below:
//a[(contains(#id, 'xx'))=false]

Related

Gremlin: toLowerCase() not working properly

I have a vertex called 'city' that has property [cityName] "Miami" and property [syonyms] "Miami^Magic City^Little Cuba".
The following query returns no results:
g.V().hasLabel('city').has('syonyms',filter{it.get().toLowerCase().contains('Miami')})
While this query gives me the results that I want:
g.V().hasLabel('city').has('syonyms',filter{it.get().toLowerCase().contains('miami')})
I thought that the "toLowerCase()" would convert "Miami" into all lower case, but it doesn't seem to be doing that. Any ideas?
Adding toLowerCase() at the end of the value within "contains" solved the issue.
g.V().hasLabel('city').has('syonyms',filter{it.get().toLowerCase().contains('Miami'.toLowerCase())})

Multiples document s types refinementfilters

i am using rest api search to get documents with certain extensions types.
I am having this code:
&refinementfilters=or'(fileExtension:equals("aspx"),fileExtension:equals("wmv"))'
The whole code is:
https://myUrl/_api/search/query?selectproperties='Path,Url,Title,Size,IsDocument,PictureUrl,LastModifiedTime'&querytext='wildlife'&refinementfilters= '(fileExtension:equals("aspx"))'
i would like to use rest api refinementfilters fileExtension using or, but the syntax with the OR condition doesn' t work, can you halp me point out
where the problem can be ?
Cheers
To apply multiple filters via refinementfilters property, replace
refinementfilters='(fileExtension:equals("aspx"))'
with
refinementfilters='fileExtension:or("aspx","wmv")'
Example
/_api/search/query?selectproperties='Path,Url,Title,Size,IsDocument,PictureUrl,LastModifiedTime'&querytext='*'&refinementfilters= 'fileExtension:or("docx","pdf")'
As far as general syntax, the quotes for the OR are in the wrong place:
Original version:
&refinementfilters=or'(fileExtension:equals("aspx"),fileExtension:equals("wmv"))'
Corrected version:
&refinementfilters='or(fileExtension:equals("aspx"),fileExtension:equals("wmv"))'

Slim3: Routing with "where" (like on Laravel)

i'm looking for a similar solution for Slim3:
Route::get('/{name}', function ($name) {
//
}) ->where('name', 'bars|clubs|discos');
So a route should handle 3 different names.
Any idea?
Thanks!
According to docs, you can add a regular expression inside the placeholder definition
$app->get('/{name:bars|clubs|discos}', callback);

SAPUI5 TableSelectDialog Search Value

I'm using TableSelectDialog control where I'm also performing some search. In order to get the search value on livesearch, i'm using oControlEvent.getParameters.value but it returns me undefined as I see it in an alert box.
Any idea why it is giving me undefined or any other way I can get the value I typed in search field.
This works with oEvent.getParameters().value.
Another idea, as most used way to find the query value is for a SeachField, we use
oEvent.getSource().getValue
Here, you can also find the query string similarly:
oEvent.getSource()._oSearchField.getValue()
Adding to the other answers here you can also do:
onSearch: function(oControlEvent) {
oControlEvent.getParameters("value");
}
https://sapui5.hana.ondemand.com/#/api/sap.m.TableSelectDialog/events/search

Possible to isElementPresent(:id, "id") in watir webdriver

Using Watir Webdriver, I wanted to have a helper that would check for any element with given id. I may not know what type it is ( button or link or text). Can I just do
browser.Element(:id, id).exists
All of the examples i've found on google check against a specific element type, as in
browser.button(:id," ").exits
If there is a way, please share the syntax.
In Watir-Webdriver, I would use something like this:
browser.element(class: 'post-tag').exists?
which would find the watir-webdriver tag on this page and report that it exists. Note that I used the 1.9 syntax instead of the alternative syntaxes of:
browser.element(:class => 'post-tag').exists?
or
browser.element(:class, 'post-tag').exists?
As Dave points out, there is #element method. (You were wrong just in capitalization, it is not #Element.)
Since you are asking about accessing it using id attribute, try this:
browser.element(:id => id)
I've never gotten .exists? to work right on it's own.
What I've had to use in these cases has been to explicitly validate the "exist?"... like:
cf_checbox = #browser.text_field(:id=>'continue-ring', :value=>true).exists?
assert( cf_description == true)
without that explicit assertion, I would always get a "true" even when the value didn't exist.