This is my scenario - I have a grid in the application . The grid contains Filters with check box . When check box is selected the filter will be applied on the application .
I have written the xpath to select a checkbox (ex: //div[text()='FirstFilter']/div) this will select the FirstFilter check box .
I want to parameterize the Xpath such that if any filter name is given that filter check box should be selected.
I am unable to find options to paarmaeterize the xpath in trueclient .
Any suggestions please .
You can take a String filterName and then using that, can parameterise the xpath like:
String filterName = null;
// Insert the value in the filterName according to your requirements
WebElement element = driver.findElement(By.xpath("//div[text()="+filterName+"']/div"));
Related
I have a dropdown list which is always increasing in the number of options available. I Have the 'RecieptName' from the option, however, it is followed by text that is constantly changing. eg: RecieptName: 'Changing sentence including words and numbers'.
What I am trying to do is something along the lines of:
cy.get('#RecieptName').select('RecieptName:');
However, it can't find an option with it as it is followed by changing the numbers. Is it possible to find the option based on a partial option?
You would need to scan the options first, find it's index and select by number
Using .contains() command
cy.get('option')
.contains('ReceiptName:')
.invoke('index') // index among siblings
.then(index => {
cy.get('dropdown').select(index);
})
Using a regex
cy.get('option')
.contains(/^ReceiptName:/)
.invoke('index') // index among siblings
.then(index => {
cy.get('dropdown').select(index);
})
Using selected prop
cy.get('#RecieptName option')
.contains(/^ReceiptName:/)
.invoke('prop', 'selected', true)
The option containing the the text "RecieptName:" can be selected by adding :contains()
cy.get('#RecieptName option:contains(RecieptName:)')
.then($option => {
cy.get('#RecieptName').select($option.text())
})
cy.get('#RecieptName option:contains(RecieptName:)')
.then($option => {
cy.get('#RecieptName').select($option.index())
})
filter will get the DOM element that match a specific selector. Once we get the element, then we get the exact text of RecieptName option by using the invoke(text) and then we pass the same text to the select command, something like this:
cy.get('#RecieptName option')
.filter(':contains("RecieptName:")')
.invoke('text')
.then((recieptNameText) => {
cy.get('dropdown').select(recieptNameText)
})
You can also use the value attribute to directly select the dropdown as I can see the value attributes are unique, I guess that would be the cleanest way to do this:
cy.get('select#RecieptName').select('scoredesc')
cy.get('select#RecieptName').select('modifieddesc')
cy.get('select#RecieptName').select('createdasc')
I have a grid with filter header in every columns. When the user type something in a filter, the datasource send a request to the server to get the data. This is fine when is only one column filter. The problem is when the user after obtain the filtered results needs to filter by another column, and without to remove the previous filter type something in other column filter. In this second situation i need to send all filter values and not only the second filter.
You don't mention what language you use. I assume you do it with javascript.
So you can use the code below.
var grid = $('#ClientsGrid').data("kendoGrid");
grid.dataSource.filter({
field: "client_status",
operator: "eq",
value: "2"
If you need to clear all filters, you can use
var grid =('#ClientsGrid').data("kendoGrid");
grid.dataSource.filter({});
How to get attribute value of multiple selection in the Owebia shipping method?
My Owebia code below:
{count items where array_match_any(product.attribute.**shipping_restriction**.**value**', array('AU','NZ','AU,NZ'))}
But,I can't get the attribute value,I only can get the id num of attribute,
shipping_restriction is my custom attribute,which has a multiple selected menu.
It just return the index num,not 'NZ' or 'AU',it just return the index num,not 'NZ' or 'AU'
If I have changed the multiple selected menu into single selection,it could get right value. Like 'NZ' or 'AU',and not index num.
You can try by using following syntax to get value.
product.attribute.*.value
Where * is attribute placeholder.
Reference: http://www.owebia.com/os2/en/doc#formulas_variables_product
I am using BaseX as backend to store XML Files. Front end is in Java. I want to populate
certain elements data into a combobox. The output of the XQuery is string. I am facing problem to load this string in a combobox. Below is the XML file-
<Cities>
<City><C>London</C></City>
<City><C>New Delhi</C></City>
<City><C>Mumbai</C></City>
<City><C>Moscow</C></City>
<City><C>Tokyo</C></City>
<City><C>Mumbai</C></City>
<City><C>Tokyo</C></City>
<City><C>Mumbai</C></City>
<City><C>Tokyo</C></City>
<City><C>Mumbai</C></City>
<City><C>New Delhi</C></City>
</Cities>
Using this XML file, I want to populate all the distinct cities in a combobox. This will be done by following XQuery-
for $x in distinct-values(doc("City")/Cities/City/C)
return $x
The output of this is a simple string -
`London New Delhi Mumbai Moscow Tokyo`
There are 5 cities resulting from the query.
How can I populate this in a combobox..?
This might help:
element select {
distinct-values(doc("City")/Cities/City/C) ! element option { . }
}
I'm using WatiN to do some web testing and have run into a problem with a select list.
I have to run through a few pages first, adding a 'Category' element that will populate said troublesome select list.
I have been able to easily select an element from the list using ByValue, but the problem here is that the values is more of an index element that is created on the fly with a seemingly random value when the 'Category' element is created. I have tried to use the text that is under the option list in the html but it cannot seem to find it.
At this point I'm willing to settle for any element in the list that isn't value "-1" as this is the "Please select an option item".
Any help at all would be appreciated,
Thanks in advance
Keith 8o8
If i understand correctly maybe this can help:
OptionCollection options = browser.SelectList("elementId").Options;
options[0].Select();
Here is a solution :
SelectList list = _browser.Frame(Find.ById(frameId)).SelectList(listId);
foreach (Option tempOption in list.Options)
{
string value = tempOption.Text;
if (!string.IsNullOrEmpty(value)) // Compare with visible option text
{
if (value.Equals(option))
{
list.Option(option).Select();
found = true;