This is a migrated thread and some comments may be shown as answers.

KendoDropDown not selecting item that is not visible

3 Answers 497 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
martin
Top achievements
Rank 1
martin asked on 09 Dec 2019, 12:24 AM

Hi

The Testing framework doesn't seem to be able to select an item in a KendoDropDownList that is not visible at runtime, though the item exists in the drop down when scrolling down to the bottom of the list.

 

Attached is a project containing two tests (Success and Failure tests), the "Success" test is selecting items at the top of that list which are visible and the "Failure" test is selecting items towards the bottom of the list that are not visible unless you scroll down.

 

Many thanks.

3 Answers, 1 is accepted

Sort by
0
Accepted
Elena
Telerik team
answered on 11 Dec 2019, 04:22 PM

Hi Martin,

Thanks for preparing a sample to demonstrate the misbehavior you encountered. 

I reviewed the two unit tests provided and also executed these against the sample demo page. First thing to recommend for this scenario is to use the Click() method instead of MouseClick(). The MouseClick() method performs a desktop click and it requires the target element to be visible on the screen. This, however, is not ideal for the current scenario and using the Click() method will work fine. 

Another good practice is to use execution delays and wait steps between the actions, which rely on elements, which need to be first loaded. This is the case with the dropdown controls - usually the dropdown list does not exist when not shown on the screen and it is dynamically loaded within the DOM tree. So, a wait for exist step between the combo toggle and click on item action will avoid any misfailures. 

Having in mind the above notes, the failing unit test from the sample project should look as below in order to be successfully executed.

public void TestMethodFailure()
        {
            Manager.LaunchNewBrowser(BrowserType.Chrome);

            ActiveBrowser.NavigateTo("http://demos.kendoui.com/web/dropdownlist/cascadingdropdownlist.html");

            //Select Produce
            KendoInput dropdownlist = Find.ByExpression<KendoInput>("aria-owns=categories_listbox");
            dropdownlist.ToggleCombo();

            HtmlListItem item = Find.ByContent<HtmlListItem>("Produce");
            item.Wait.ForExists(5000);
            item.Click();

            System.Threading.Thread.Sleep(2000);

            //Select Product
            KendoInput dropdownlistProducts = Find.ByExpression<KendoInput>("aria-owns=products_listbox");
            dropdownlistProducts.ToggleCombo();

            HtmlListItem itemProduct = Find.ByContent<HtmlListItem>("Tofu");
            itemProduct.Wait.ForExists(5000);
            itemProduct.Click();
        }

Please, give this a try on your end as well and let me know if there are any further questions on the topic.

Thank you in advance for your time and cooperation.

Regards,
Elena
Progress Telerik

 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
martin
Top achievements
Rank 1
answered on 11 Dec 2019, 11:45 PM

Brilliant Elena, working like a charm.

I had used the following example to base the test case on, the response is a few years old but was the only example I could find https://www.telerik.com/forums/translator-for-kendo-dropdownlist

Many thanks,

Martin

 

 

0
Elena
Telerik team
answered on 12 Dec 2019, 08:36 AM

Hello Martin,

I am pleased to know that worked for you and the shared details will be useful for you in the future. 

Please, do not hesitate to contact us again with any doubts you may have in regards the Testing Framework.

Regards,
Elena
Progress Telerik

 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
martin
Top achievements
Rank 1
Answers by
Elena
Telerik team
martin
Top achievements
Rank 1
Share this question
or