How to truncate text in kendo's expansion panel component - kendo-ui-angular2

I have a very simple, but quite tricky, question: I need to display a title of a post using kendo's expansion panel component in Angular. The tricky part is that I don't want it to exceed the length of 10 characters. The code I wrote is:
<div class="wrapper">
<kendo-expansionpanel
*ngFor="let data of datas"
[title]="data.title | slice:0:6"
[subtitle]="'from ' + data.userId"
[expanded]="false"
class="col-6">
<span class="content-text">{{data.body}}</span>
</kendo-expansionpanel>
</div>
I thought that the line:
[title]="data.title | slice:0:6"
would work, but I keep getting the error:
Type 'unknown[]' is not assignable to type 'string'
How can I solve it?

Related

How to click on Web check box using Excel VBA?

How do I check the table checkbox?
I tried clicking.
ie.Document.getElementsByClassName("x-grid3-hd-checker").Checked = True
<div class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on" unselectable="on" style="">
<a class="x-grid3-hd-btn" href="#"></a>
<div class="x-grid3-hd-checker"> </div>
<img class="x-grid3-sort-icon" src="/javascript/extjs/resources/images/default/s.gif">
</div>
I can't see a checkbox in the HTML code. But you use getElementsByClassName() in a wrong way for your case. getElementsByClassName() generates a node collection. If you need a specific node, you must get it by it's index in the node collection. First element has index 0.
Please note that the div tag with the CSS class class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on " is also included in the Node Collection, because a part of the class identifier is identical to "x-grid3-hd-checker ". [Edit: I'm not realy sure if the part must maybe stand at the begin of the identifier]
If you want to check this:
<div class="x-grid3-hd-checker"> </div>
Your code needs the second index of the node collection:
ie.Document.getElementsByClassName("x-grid3-hd-checker")(1).Checked = True
But if there are more tags with the class name "x-grid3-hd-checker" the above line don't work. I can't say anymore until you don't post more HTML and VBA code. The best would be a link to the site.

How to input text to non standard input elements

I'm faced with a span element for text input instead of an input box, and I'm struggling to use Watir (Ruby) to enter text. There's no set method, there is a text method that returns the text fine, but I don't seem to be able to set the text that way.
I've also tried using span.select and span.focus and then browser.send_keys but nothing is input in the field.
<div class="UFIAddCommentInput _1osb _5yk1">
<div class="_5yk2" tabindex="-2">
<div class="_5rp7">
<div class="_1p1t">
<div class="_1p1v">
Write a reply...
</div>
</div>
<div class="_5rpb">
<div aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_3i" class="_5rpu" contenteditable="true" data-testid="ufi_reply_composer" role="combobox" spellcheck="true" title="Write a reply..." id="js_3j">
<div data-contents="true">
<div data-block="true" data-offset-key="8c176-0-0" class="_45m_ _2vxa">
<span data-offset-key="8c176-0-0">
<br data-text="true">
</br>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
What could I try next? Is there a way to stop front end designers using non-standard elements?
You can use javascript to do this. The difficulty for me was to handle the nested quotes.
Two pieces of knowledge I had to figure out first before being able to do this w/ regards to nested strings:
a.) regarding how javascript handles nested quotes: http://www.w3schools.com/js/js_strings.asp
b.) on how to deal with nested quotes in ruby: Escaping single and double qoutes from a string in ruby (the %Q operator lets you set whatever you want to begin and end a string)
css_selector = "span[data-offset-key='8c176-0-0']"
b.execute_script(%Q|query="#{css_selector}"|)
b.execute_script("document.querySelector(query).innerHTML='that was tricky'")
Looks like the ability to inject JavaScript using procedures such as this enables you to be able to do just about anything Watir can't do otherwise. Good question, this was a learning experience for me too

Align top left and bottom right with material design

I might be getting this completely wrong, but trying to create a webpage where Div 1 is in top left corner, and div 2 is aligned bottom right (or end end). And I wanted to do this in the right way using material design.
I want it like this (sorry for the ASCII art, but it is cool)
_____________33____50________________
| | |
| 1 | |
| | _________________| 33
-------------| | |
| | 2 |
| | |
| | |
--------------------------------------
50
Here is the code so far, but the problem is I can get it to affect the alignment on column one, but I cant set them independently on the two divs
<md-content layout="column" layout-fill>
<div layout="column" flex="33"><H1>Welcome to My page</H1>
</div>
<div layout="row" layout-align="end end" flex="33">
<div layout="column" layout-align="end end" flex="50">
<H3>Welcome to my page</H3>
<p>This is my page, there are many like it <bold>But this page is mine</bold></p>
<ul>
<li>
My page is my best friend
</li><li>
I must master its code
</li><li>
like I must master my life
</li>
</ul>
</div>
</div>
</md-content>
Not certain the JS fiddle works at all, managed to get the first bit working, but cant get the end. Is this just because we don't know how big the screen is?
Here is a simple JS fiddle, and Material Design is working, and I can get the flex to work, but not the align
https://jsfiddle.net/p02Ls1dh/3/
OK, sorry, me being silly, material design still don't know the height, so the way to do it is to set height (you can use javascript and window) to set the height to say 900px (style="height: 900px;" below), once that is done it works.
<md-content layout="column" layout-fill style="height: 900px">
<div layout="column" flex="33"><H1>Welcome to My page</H1>
</div>
<div layout="row" layout-align="end end" flex="33">
<div layout="column" layout-align="end end" flex="50">
<H3>Welcome to my page</H3>
<p>This is my page, there are many like it <bold>But this page is mine</bold></p>
<ul>
<li>
My page is my best friend
</li><li>
I must master its code
</li><li>
like I must master my life
</li>
</ul>
</div>
</div>
</md-content>

Python 3 BeautifulSoup4 search for text in source page

I want to search for all '1' in the source code and print the location of that '1' ex: <div id="yeahboy">1</div> the '1' could be replaced by any other string. I want to see the tag around that string.
Consider this context for example * :
from bs4 import BeautifulSoup
html = """<root>
<div id="yeahboy">1</div>
<div id="yeahboy">2</div>
<div id="yeahboy">3</div>
<div>
<span class="nested">1</span>
</div>
</root>"""
soup = BeautifulSoup(html)
You can use find_all() passing parameter True to indicate that you want only element nodes (instead of the child text nodes), and parameter text="1" to indicate that the element you want must have text content equals "1" -or any other text you want to search for- :
for element1 in soup.find_all(True, text="1"):
print(element1)
Output :
<div id="yeahboy">1</div>
<span class="nested">1</span>
*) For OP: for future questions, try to give a context, just like the above context example. That will make your question more concrete and easier to answer -as people doesn't have to create context on his own, which may turn out to be not relevant to the situation that you actually have.

Newbie Cucumber scope question

I am trying to check for the "style='width:60%'" bit in the html below
<div class='pers-ref-rate'>
<div class='rating-type'>
Reliability
</div>
<div class='type-reliable rating'>
<div style='width:60%'></div>
</div>
</div>
I have got the line
And I should see a personal reliable rating of 60
and the following in my steps
Then /^I should see a personal (\w+) rating of (\d+)$/ do |rating_type, rating|
with_scope("div.type-#{rating_type}") do
page.should have_css('.rating', :style => "width:#{rating}")
end
end
I am getting an error
RSpec::Expectations::ExpectationNotMetError: expected #has_css?(".rating") to return true, got false
I stole the steps from another project and adapted it slightly (it was using ids not classes).
What have I done wrong?
Thanks in advance for any help.
Mark
That's looking for a
<div class="rating" style='width:60%'></div>
within the scope of
<div class='type-reliable rating'></div>
To make it work, either add the rating class to that div, or remove the css search for .rating in it.
hth

Resources