Playwright: Find icon by classname in near range of a defined text - playwright

Good evening,
I would like to ask if someone knows, if it's possible in Playwright to check if an icon - under certain conditions - is visible?
The conditions are:
the icon has a specific name, but appears multiple times on the site
it has to be in a certain range (lets say 15 pixel) of a unique text
My first idea was something like this...
await expect(page.locator('icon:near(:text("Specific text"), 15)'))
...but as you can see, I miss the option to declare the icons classname
Thanks in advance and have a nice evening.
finethen

According to the Playwright docs on matching by layout, those matchers “can be combined with regular CSS to pinpoint one of the multiple choices.”
If I’m understanding correctly that any css can be used, then you should be able to use the class name just fine. So basing off your example, you should be able to do something like
.yourclassname:near(:text("Specific text"), 15)
Hope that works for you!

Related

Excel Hyperlink Function - Display Nice Name?

I found this formula online. It takes a cell, and handles the hyperlink, based on the excel spreadsheet being in the root folder, so the files being hyperlinked are in that directory (or sub-directory). This is the formula:
=HYPERLINK(LEFT(CELL("filename"),FIND("|",SUBSTITUTE(CELL("filename"),"\","|",LEN(CELL("filename"))-LEN(SUBSTITUTE(CELL("filename"),"\",""))))) & C2)
I would like to have it say something like "Click Here to Open" or something nice. I can certainly handle that in another cell, if that would be easier, but I'm not seeing a way to do that. Anyone know how to handle this?
We don't want the users to see D:\blah\folder\filename.pdf
It looks messy and would like something nicer.
Thanks!
Nevermind. I found it was as simple as adding
,"nicename")
OR
,A2)
to get the name I want.
Duh.

How to copy class and function name in Blackfire report

When I am copy-pasting method name from Blackfire profile, I am getting a reversed string like this:
sgnitsiLredivorPdaol::yrotisopeRresopmoC\yrotisopeR\resopmoC
What is intended way to copy a proper method name (not reversed)?
Why does Blackfire has such behaviour? Is this some kind of stupid joke or copy-paste protection?
This is indeed a UX issue we currently have in Blackfire, let me explain it to you:
We want to display the end of the namespace/classname value in this part of the interface
We want to have a text-overflow ellipsis on the left part of the value.
Unfortunately, using text-overflow: ellipsis on the left of the text is not supported by modern browsers at the moment.
There are two ways to do that: Either know the width of the text, work with a fixed width column and truncate programmatically or use a hack, revert the letters, change the text direction from left-to-right to right-to-left locally and use traditional text-overflow.
As we deal with a resizable UI here, we chose the second option, and this is the one that provide the better experience at the moment. However, as you notice, this issue remains.
We're thinking about a fix for this issue. It might be with the Clipboard API.
In the meantime, here's the way you can copy/paste the value :
Just expand a node and copy from the inner box, see:
Hope it helps you until we find a better solution.

iOS Custom Keyboard, Suggestions from txt file

I'm making a custom keyboard for lawyers, and trying to load law related words in suggestion/prediction bar on top the keyboard based on what user types. Just like in stock keyboard. I have searched around but did not find any concrete answer.
I want to display suggestions of law related terms that I have in a txt file, all words are sorted alphabetically.
DEMO
Here is what I have tried:
UILexicon
let myLexicon = NSMutableDictionary()
self.requestSupplementaryLexiconWithCompletion { (theLexicon: UILexicon!) -> Void in
let lexiconEntries = theLexicon.entries
// Completion handler
for item in lexiconEntries {
self.myLexicon.setObject(item.documentText, forKey: item.userInput)
}
}
This code just gives 23 nil objects.
UITextChecker This is an iOS class that is designed to spot spelling errors, which makes it perfect for knowing if a given word is real or not. This is seems to be mainly for autocorrection, not for suggestion. Correct me if I'm wrong please.
I cannot somehow make sense out of these two classes.
How do I tell custom keyboard, "Hey if user enters "V" show the top 3 words that start from V, then if user enter a, fill the suggestion bar with words that start with "Va" and so on.
EDIT: Looks like someone ran into same problem. Here is a quote how they solved it, I will update with code once I finish figuring this out myself.
However, this was far from the truth - in fact, Apple do not allow access to their dictionary full stop, only offering a UILexicon class instead as stated in their docs:
Make use of this class, along with a lexicon of your own design, to provide suggestions and autocorrections as users are entering text.
As it turns out, the UILexicon class only really contains contact names along with any shortcuts (like the default On My Way!) defined on the device. So before writing the logic for a keyboard, you first have to implement your own autocorrect library.
We browsed through a few external projects to see if we could include them in the keyboard - most notably Hunspell, which is used by OpenOffice, and Presage, an intelligent predictive text library.
I spent a long time integrating the C++ libraries with the code, but in the end, in order to keep complexity down, we opted to use a combination of UITextChecker (which provides some basic corrections) and our own custom dictionary, containing a few commonly mispelled words.
Link to the Article
Thanks!
You have to implement your own autocorrection system. UILexicon will only give you shortcuts the user has set up, words that they have added to the iOS Dictionary, and names of contacts. It has no awareness of any words that you yourself provide, whether in a txt file or in any other form.
If you want to use the TOMSSuggestionBar, it appears from the sample code that the onus is on you to convert your txt file into a core data model, and indicate to the suggestion bar how it is to interpret the contents of that model. You may also want to implement the data source protocol to get more fine grained control over the suggestions.
Autocorrection and next word prediction are not solved problems; I suggest you do your own research and find the solution that is best suited to your goals.

angular dart >> Best way to create a table:column renderer

I'm hopping this awesome community can steer me on the right direction. I came from the flash/flex/js world, and I like how simple it is to define an item renderer in flex. Here is what I'm trying to accomplish:
I have an Angular component which consist of a form and a html table. I have the columns, headers, rows, etc. all populating correctly using ng-repeat. I want to be able to define column "renderers", so if someone passes me a column property like "renderAs: 'button'" or "renderAs: 'progress'" I should be able to render the entire column as a button, or progress bar, etc.
Here is what I've tried so far:
ng-bind-html="getColRenderer(column.renderAs, column.value)" which
returns HTML based on 'renderAs'. As you all probably know, this
will only work with basic HTML stuff, but I cannot append an
'ng-click', or an 'href' due to angular's security. So, I opted
for something else.
I semi-have a good solution embedding a "ng-switch" inside my
ng-repeat. I had an ng-if but with several types of potential
"renderers" I opted for the switch. This somehow seems like future
problems while trying to display too many columns or rows, just my
fears.
Decorators - I like decorators, but it seemed a bit too much for
something as a simple button that calls something on click or a
progress bar with 2 values. So, I halted going into this path, but
if this is the shinning path all walk, then by all means.
I hope someone out there has ran/done something like this and can steer me on the right course of action. If the ng-switch or ng-if is okay, then I'm good to go.
Once again, thank you in advanced.

auto_complete_for: prevent the first item from being auto-selected

The auto_complete_for dealio from script.aculo.us is great an all, but is there a way for me to selectively disable the fact that it always auto-selects the first item in the list?
The problem is that, if I want to type my own entry that is new, and novel, I don't want the first item in the list to be auto-selected. The reason is because when I TAB out of the field, it selects, and fills the text box with that first item.
I got around that, somewhat, by making the first item in the list the same as what I'm typing, but that's not perfect either, because the auto_complete list doesn't always update with every keystroke, depending on how fast I type. I've tried setting the list refresh rate to the lowest value (1 millisecond) but no go.
What I really want is an option in "auto_complete_for" that doesn't select that first item at all - the same way that Google Instant doesn't automatically select the first suggested search phrase - you have to arrow-down to select one.
Maybe I can do this via an HTML option that I'm missing?
Looking at the source, there doesn't appear to be an option for that, but I bet if you changed line 284 of controls.js to this.index = -1; it would do what you want.
Otherwise, it might be time to look for a different autocomplete widget.
If your requirements are too far away from the available plugin, then I guess there is no point in tinkering around. Its best to write your own JS code.
You might want to consider this: https://github.com/laktek/jQuery-Smart-Auto-Complete
or this : https://github.com/reinh/jquery-autocomplete
I'll add another alternative that works great with Rails 3:
http://github.com/crowdint/rails3-jquery-autocomplete
I recently implemented auto complete for more than a field for Rails 2.0.2.
The plugin I used is:- https://github.com/david-kerins/auto_complete . Not sure if it supports Rails 3.
I have also encountered issues on implementing the above scenario and have posted questions( Implementing auto complete for more than one field in Rails ; Implementing a OnClick kind of functionality and formatting wrt Rails Partial-Views ) on stackoverflow for the same, I have been lucky on getting things working for me based on my requirement.
Kindly refer to these questions, they might have relevance to your requirement.

Resources