Clear text field for Kendo UI

1,564 views
Skip to first unread message

vasanth kumar

unread,
Jul 15, 2015, 11:44:42 AM7/15/15
to seleniu...@googlegroups.com
Hi Guys,

i had come across the problem like not able to clear the text in field and not able send new value for kendo UI. i read so many solutions form user group and followed , still problem is not resolved.

Please help me with this .

MY HTML CODE 
span class="k-numeric-wrap k-state-default k-state-hover">
<input id="PortKendoWrapper" class="k-formatted-value k-input" type="text" tabindex="0" style="display: inline;" title="" aria-disabled="false" aria-readonly="false"/>
<input id="Port" class="k-input" type="text" data-bind="attr: {id: Name()}, kendoNumericTextBox: { value: Value, enable: Enabled, decimals: ParameterMetadata().Scale, format: Format, min: ParameterMetadata().Minimum, max: ParameterMetadata().Maximum }" data-role="numerictextbox" role="spinbutton" style="display: none;" aria-valuemin="1" aria-valuemax="65535" aria-valuenow="80" aria-disabled="false" aria-readonly="false"/>

I have tried in 
driver.findElement(By.xpath(".//*[@id='PortKendoWrapper']")).clear();
driver.findElement(By.xpath(".//*[@id='PortKendoWrapper']")).sendKeys("1000");

or 

driver.findElement(By.id("Port")).click();
driver.findElement(By.id("Port")).sendKeys(Keys.chord(Keys.BACK_SPACE)),"50");  
driver.findElement(By.id("PortKendoWrapper")).sendKeys("50");


Thanks in Advance for answers

Vasanth

Kartik Shah

unread,
Jul 16, 2015, 1:43:35 AM7/16/15
to seleniu...@googlegroups.com

Hi Vasanth,

What is the value of the text box? Is it 80? If that is the case then it seems Developer has added tags to store the value for the field instead of default way.

can you try writing javascript to override the values to null?

Code:

IJavaScriptExecutor js = driver as IJavaScriptExecutor;

js.ExecuteScript("document.getElementById('PortKendoWrapper').setAttribute('aria-valuenow','')");


Thanks,

Kartik Shah

 


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/d85518e9-6627-4d0f-8d3b-e57801851c85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vasanth kumar

unread,
Jul 16, 2015, 1:59:13 AM7/16/15
to seleniu...@googlegroups.com
yes karthik , value is 80 and it has increment\decrement icon . please find the attached screenshot below.

Inline images 1

i will try using java script..

thanks..




For more options, visit https://groups.google.com/d/optout.



--
Thank's & Regard's
Vasantha Kumar

Kaleem Uddin Mohammed Abdul

unread,
Jul 17, 2015, 11:15:47 AM7/17/15
to seleniu...@googlegroups.com

This is what I did in C# to handle Kendo Grid UI filters. Basically in my project they have String, Integer and DomainList filters. So I have divided my code into these 3 parts.

  /// <summary>
        /// This method is used to Perform based on the Column Name.
        /// Column Name should be same as it is displayed in the Grid.
        /// </summary>
        /// <param name="ColumnName">Column Name of the Grid.</param>
        /// <param name="SearchCriteria">Search Criteria applicable for Column Ex:Contains</param>
        /// <param name="SearchText">Search Text=Filter Text which needs to be applied on the Column.</param>
        /// <param name="ButtonToBeClicked">Filter OR Clear.</param>
        public void PerformFilter(string ColumnName, string SearchCriteria, string SearchText, string ButtonToBeClicked)
        {
            ArrayList TempList = new ArrayList();
            try
            {
                #region Get all the colums from the table and add in Data Column Collection
                IList<IWebElement> ColumnList = WorkQueueGridColumns;
                for (int ColumnCounter = 0; ColumnCounter < ColumnList.Count; ColumnCounter++)
                {
                    IWebElement ColumnElement = ColumnList[ColumnCounter];
                    string GridColumnName = ColumnElement.GetAttribute("data-title");
                    if (GridColumnName != null)
                    {
                        GridColumnName = GridColumnName.ToLower();

                        if (GridColumnName.Equals(ColumnName.ToLower()))
                        {
                            IWebElement Element = ColumnElement.FindElement(By.TagName("span"));
                            IJavaScriptExecutor JSE = _WebDriver as IJavaScriptExecutor;
                            JSE.ExecuteScript("arguments[0].scrollIntoView", Element);
                            Element.Click();
                            break;
                        }
                    }
                }
                IWebElement ActiveElement = _WebDriver.SwitchTo().ActiveElement();
                IWebElement FilterButton = ActiveElement.FindElement(By.XPath(@"ancestor::div[count(@*)=0]//button[@type='submit']"));
                IWebElement ClearButton = ActiveElement.FindElement(By.XPath(@"ancestor::div[count(@*)=0]//button[@type='reset']"));

                BuildControlsForFilter(ActiveElement, ColumnName, SearchCriteria, SearchText);

                if (ButtonToBeClicked.ToLower().Equals("filter"))
                {
                    FilterButton.Click();
                }
                else if (ButtonToBeClicked.ToLower().Equals("clear"))
                {
                    ClearButton.Click();
                }
                #endregion
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
        private void BuildControlsForFilter(IWebElement ActiveElement, string ColumnName, string SearchCriteria, string SearchText)
        {
            try
            {

                List<string> ColumnsListtWithInputText = new List<string>();
                ColumnsListtWithInputText.AddRange(new string[] { "Company Name", "Owner", "Order SI", "Setup SI","Service Type","Product",
                                                                  "Country","LOB","Customer#","Order Contact Name","Order Contact Email",
                                                                  "Order Contact Phone","Order#"});

                List<string> ColumnsListtWithInputNumber = new List<string>();
                ColumnsListtWithInputNumber.AddRange(new string[] {  "Tie#", "Tie Count", "TimeInQueue(Days)","BUID","TimeInSetup(Days)",
                                                                  "Unit Qty"});


                List<string> ColumnsListtWithDomainValues = new List<string>();
                ColumnsListtWithDomainValues.AddRange(new string[] { "Status", "Region" });

                bool FoundInInputTextList = ColumnsListtWithInputText.Exists(x => x.ToLower().Equals(ColumnName.ToLower()));

                bool FoundInInputNumberList = ColumnsListtWithInputNumber.Exists(x => x.ToLower().Equals(ColumnName.ToLower()));

                bool FoundInDomainList = ColumnsListtWithDomainValues.Exists(x => x.ToLower().Equals(ColumnName.ToLower()));

                IWebElement DropDownIcon = ActiveElement.FindElement(By.XPath("ancestor::div[count(@*)=0]//span[@class='k-icon k-i-arrow-s']"));
                DropDownIcon.Click();
                IWebElement CurrentActiveElement = _WebDriver.SwitchTo().ActiveElement();

                CurrentActiveElement.SendKeys(SearchCriteria);
                IWebElement InputText = null;
                if (FoundInInputTextList)
                {
                    InputText = ActiveElement.FindElement(By.XPath("ancestor::div[count(@*)=0]/input"));
                    InputText.SendKeys(SearchText);
                }

                else if (FoundInInputNumberList)
                {
                    InputText = ActiveElement.FindElement(By.XPath("ancestor::div[count(@*)=0]//input[@class='k-formatted-value k-input']"));
                    InputText.SendKeys(SearchText);
                }

                else if (FoundInDomainList)
                {
                    InputText = ActiveElement.FindElement(By.XPath("ancestor::div[count(@*)=0]//span[text()='-Select value-']/parent::span//span[@class='k-icon k-i-arrow-s']"));
                    InputText.Click();
                    IWebElement Element = _WebDriver.SwitchTo().ActiveElement();
                    Element.SendKeys(SearchText);
                }
            }
            catch (Exception Ex)
            {
                throw Ex;

Ilya

unread,
Jul 18, 2015, 11:31:44 PM7/18/15
to seleniu...@googlegroups.com
Hi Vasanth,

I had the exact same problem today.The solution is quite simple! Notice that under that you have two input's under that span.

The first path is for when the field ins't active (i.e. you haven't clicked on it yet), and the second one is for when it's active (i.e. you clicked it).

So the solution here to click on the first path, then sendKeys to second path. 

Worked like a charm, no need to changes attributes.

Hope this helps!
Reply all
Reply to author
Forward
0 new messages