In Ext js how to highlight text in grid if it matches searching criteria - extjs4

I have one grid and text box. I want to highlight values in grid which matches with value in text field.
For example, in firefox, if you press cntrl + F4, you will see one text box and you write a value which you want to find. Firefox hightlights string mathing with this value.
Can we do like this in extjs? How?

There is an example of exactly that here:
http://docs.sencha.com/extjs/4.2.1/extjs-build/examples/grid/live-search-grid.html

Sandeep, the trick to the highlighting is actually in the CSS.
You can navigate to ../examples/ux/css/LiveSearchGridPanel.css to find the following code:
.x-livesearch-match {font-weight: bold; background-color: yellow; }
You can add the CSS href to your index.html, or add this code to your css
Hope this is what you were able to figure out.

Related

Selenium xpath - Unable to find the xpath

I need to get the text "No results found, click tab to use entered text" from below html.
<div id="boundlist-1520-listEl" class="x-boundlist-list-ct" style="overflow: auto; height: auto;">
<ul></ul>
No results found, click tab to use entered text
</div>
When I tried with div id, its throwing the error.
Can anyone help me to get the xpath of this.
Many Thanks.
Regards,
Sudha Banakar
I guess Your id is changed dynamically so that you need to identify it by start with or contains method.Following XPath will work for you
"//div[starts-with(#id,'boundlist-')]
You can verify XPath by pasting it on your google chrome console
$x("//div[starts-with(#id,'boundlist-')]")
The xpath is :-
//ul[contains(text(),'No results found, click tab to use entered text')]
or best is
//*[contains(text(),'No results found, click tab to use entered text')]
If text displayed is not getting changed then you can use below xpath
//div[text()='No results found, click tab to use entered text']

How to change padding on cells within a DataGrid - VB.NET

I am trying to add padding to all of the cells within my DataGrid (not DataGridView). I want there to be space between the walls of the cell and the text within the cells. Is there any way to do this? I have looked into this and all I see is how to do it with DataGridView and not DataGrid...
Here is a picture of the DataGrid with no padding:
Notice how the the text is pushed tight to the line on the right side.
Please help! Thank you!
This is what worked for me:
I created a CSS file and added left and right padding to td:
td {
padding-left: 5px;
padding-right: 5px;
}
I then added a reference to that CSS file into the same markup file where my DataGrid is located:
<link href="YourFolderNameHere/YourCSSFileNameHere.css" rel="stylesheet" />
I did try what #TnTinMn suggested in his comment with CellPadding but had no luck.
NOTE: I am unsure if this method will work in all cases or only in my own. By doing this all td elements will take this style, which in my case is fine because I wanted all td elements within every table to have this padding style.

How to write xpath based on element's text in Robot Framework?

I am using the Robot Framework and Selenium2Library
The button has a text of "Save" and there is nothing more unique in it's xpath, so I'm trying to write an xpath based on element's text.
How to write an xpath based on element's text with that piece of html:
<button class="slds-button slds-button--brand cuf-publisherShareButton NARROW uiButton" type="button" data-aura-rendered-by="1571:2954;a" data-aura-class="uiButton">
<span class=" label bBody truncate" dir="ltr" data-aura-rendered-by="1574:2954;a">Save</span>
</button>
(this is in the middle of the document).
EDIT:
It appears that there are few elements with the same text on the next tab (which was invisible at the moment).
How should I write the xpath for the second element with this text? I mean with index=1.
Click Button //button[.//text() = 'Save']
Is the "Robot Framework" way of finding a button with the text "Save" and clicking it.
Fixed from the help of #Tomalak
<3
Try searching for a button which contains a span with your required text
WebElement saveButton = driver.findElement(By.xpath(".//button/span[text()='Save']")
Use following xpath to find a button which have text as save -
//button[contains(.,'Save')]
Use following keyword, which will first verify whether element is present or not and then it will click on element located by locator
Element should become visible xpath=//button/span[text()='Save']
Click Button xpath=//button/span[text()='Save']
There is another built in keyword
Click Element xpath=//button/span[text()='Save']
Try using below xpath:
xpath=//span[contains(text(),'Save')]
Try this -
//span[text()='Save']/ancestor-or-self::button

pdf2htmlEX text selection issue

I have converted the pdf into html using pdf2htmlEX. While selecting more than one lines, when cursor goes between two lines the selection jumps upwards. Some one please help to get this fixed.
The issue is already raised here https://github.com/coolwanglu/pdf2htmlEX/issues/62 but the solutions didn't solve the problem. Need help to fix this.
As workaround I have created this styling:
.t {
/* making selection to behave nicer when selecting text between multiple text lines (to avoid element gaps which can cause weird selection behavior) */
padding-bottom: 100px;
margin-bottom: -25px;
/* making selection to behave nicer when selecting text between multiple columns (useful for pages with 2 or more text columns) */
padding-right: 2000px;
}
Problem is that all text elements are absolute positioned and whenever mouse (during selection) leaves text element it fires mouse events on page element (which causes to select text from beginning of page to the starting point) until other text element is reached.
This styling/workaround "fills" those gaps so mouse never reaches page element.
Document should look the same.
Edit: Be aware that this solution relies on proper DOM structure (text elements are ordered). In some scenarios text can become unselectable (eg. when page contains 2 text columns and first text block is actually placed as last child in DOM).
If you get into such problem, try adjusting values to fit nicely in your document, like below:
.t {
/* making selection to behave nicer when selecting text between multiple text lines (to avoid element gaps which can cause weird selection behavior) */
padding-bottom: 40px;
margin-bottom: -10px;
/* making selection to behave nicer when selecting text between multiple columns (useful for pages with 2 or more text columns) */
padding-right: 0px;
}
Selection might jump here and there (again depends on document structure and used values), but still it will be a lot better compared to original state.

Selenium, using xpath to click a button with a similar content

I want to click a button that contains "Add" as text.
ie:
driver.find_element_by_xpath("(//a[contains(text(),'Add')])").click()
however it's not practical to do this:
driver.find_element_by_xpath("(//a[contains(text(),'Add')])[1]").click()
It would be fine, except the page has a button with text "Add User", and it clicks that instead. Is there a way to only click it if it is EXACTLY "Add" and not just contains "Add"?
You can also try :
driver.find_element_by_link_text("Add").click()
link text will match links who's text equals Add and it doesn't match text which contains Add as part of it.
This should work for you:
driver.find_element_by_xpath("//a[text()='Add']").click()
You should change your xpath to require an exact match instead of a partial match.
driver.find_element_by_xpath("//a[text()='Add']").click()
Using text()= requires the text on the button to be equal to 'Add' and will not find other buttons that happen to contain the text 'Add'