I want to show the number of search results that are going to appear in the table, is there a way to show the number of elements or do you have to compute it, ie I want to show something like this:
Found $results.size$ result$if(rest(contacts))$s$endif$.
The "s" correctly shows when there is more than one search result, but the $results.size$ returns nothing. Not sure if it matters, but im using Java, so its a List thats being passed in.
Found the answer, there is a length() function, ie:
Found $length(results)$ result$if(rest(contacts))$s$endif$.
Related
I have a problem with my code and I don't know what to do to get this to work:
I have a Redis cache system that gets the information of a user from a String value and the value of that key is something like this in the user profile in Redis cache: someinfo: "a:b:c/a:b:c/c:b:a/b:a:c" and I need to get the information of each of the information's given inside the bar but to do that properly with the split() function I would need to know exactly how much bar's are in the value, I would like to get every information inside the bar in as a variable, but the amount of bar's could be 2, 3, 4 or even 50, I don't have that information, is it even possible to do what I want? Maybe using loops? Please help me, thanks in advance.
I want to get every information of a the split from '/' and then use split again to get the other information's by splitting ':' but in order to do that I would need to know exactly how much '/' are in the String in order to use split again but I don't have that information.
I am a beginner with Cucumber/Selenium, and I have a web page on which there is a table on which one of the boxes can be 0 or 1. my problem is that the value of this box varies over time, I have tried many times to check that this element is 1 then 0 after a certain time, but I do not succeed in it.
I know how to get the css or xpath of this element, but it doesn't change when the value of this element changes, and no way to get the associated value (0 or 1) of this element.
What I've tried:
By inspecting the part of the source code associated with this element I saw that a character in the source code went from 1 to 0 at the same time as the box, and I tried to check this change with driver.getPageSource.contains ("the area around the source code that contains the changed character*"), after waiting a little with a wait instruction to allow the source code the time to change, but this has never worked.
Anyone have an idea to help me do it right? It is very important for me to find the solution to my problem,
Thank you.
If you want to get the text from an element, use:
String value = driver.findElement(By.XPath(*your XPath here*)).getText();
This will output the inner text from the element at the moment you call it. If your element doesn't have any inner text, use:
getAttribute("value")
When trying to get the value of an element, it is best practice that you specify what your element is and then try to get the value from it, rather than getting the entire page source and making sure what you expect is contained in it.
There are many resources that will help you gain an understanding of how Selenium and Cucumber work, which I would recommend having a look through before trying to build a solution.
I need to do some validation on my vaadin application. I have several textFields to check, and the first thing I need to do is to check if they are empty or not. I know there is an isEmpty method but as I have a few to check is there a better way to check them all together at the same time? Like, would it be a good idea to get the textFields in an array or List and loop through them?
Also one more thing about validation. Some of these textFields are supposed to contain integers, well, I should say, the values are supposed to be parsed as integers. A quick look in the vaadin API doesn't show any suitable method so I will check whether those strings are parsable as ints
To your first part of the question: If your fields are in a form, set the fields to required. During form.commit() the emptyness is tested automatically.
To the part with the integer-fields: You can use this on your textfields:
setConverter(new StringToIntegerConverter());
Very similar to this question, I'd like to remove the empty value that appears while async loading a ValueListBox. I won't know beforehand any value that may be rendered from my list of objects, so I cannot call setValue(beforeHandVal). Setting setAcceptableValues(Collections.emptyList()) did not work. Is there any way to do this?
I have a textfield and if I want to write something to the field, it will show me the list of possible options regarding to that letter and I think this is called an auto complete.
Could someone give me an idea or a sample on how to do it?
Thanks..
Take a combo box and listen to all changes in the textfield. On every event, read the actual content and query your source list for possible matches. Then use the result to populate the associated list.
You may want to start autocompletion once the user has entered two or three letters, otherwise the list may get too long..
look here is AutoCompleteComboBox / JFextField, and there are two classes one for JComboBox, second for JTextField, notice auto-complete functionality requires both classes for that
I feeling generous as you really should google ...
As the user types, you'd need to query your DB with a like '<userInput>%' and return the results into a pulldown. You probably want to wait for a pause in the user's typing so as not to hammer your DB.
In the absence of a database, a data structure that would work well for this is called a Trie as you can traverse it past the initial input and present all the subsequent words.