简体   繁体   English

Selenium IDE无法找到Ext JS的列标题菜单

[英]Selenium IDE cannot find Ext JS's column header menu

I have been using Ext JS for my frontend, and my grid has columns with menus on its headers (just standard impl). 我一直在使用Ext JS作为我的前端,我的网格在其标题上有一些带有菜单的列(只是标准的impl)。

The menu on the header is used to enable, or disable, filters on the store based on the values filled in it. 标题上的菜单用于根据填充的值启用或禁用商店中的过滤器。

I have just started using selenium to automate some of my frontend testing, and I figured Selenium cannot find the click action on the column header menu... 我刚开始使用selenium来自动化我的一些前端测试,我认为Selenium无法在列标题菜单上找到点击操作...

I read on the internet that we need to specify unique IDs to components so that Ext JS wont come up with dynamic generated IDs for those. 我在互联网上读到,我们需要为组件指定唯一的ID,以便Ext JS不会为这些ID提供动态生成的ID。 I set an ID to the gridcolumn xtype, but I figured that does not apply to the header menu (or the button that triggers its opening). 我将一个ID设置为gridcolumn xtype,但我认为这不适用于标题菜单(或触发其打开的按钮)。

Can anyone help me with applying an unique ID to the button that brings up the menu window, or some way to make Selenium find the header menu? 任何人都可以帮助我将一个唯一的ID应用到调出菜单窗口的按钮,或者某种方式让Selenium找到标题菜单?

Ext JS column header menu Ext JS列标题菜单

Thanks @JimGrigoryan for the advice! 感谢@JimGrigoryan的建议! After switching to Kantu's selenium on desktop mode, using XClick, XMove and XMoveRelative I was able to find elements on the page by taking screenshots. 在桌面模式下切换到Kantu的selenium后,使用XClick,XMove和XMoveRelative,我可以通过截屏找到页面上的元素。 Now it does not matter the dynamic IDs Ext Js gives to the elements. 现在,Ext Js为元素提供的动态ID无关紧要。

Try something like this 尝试这样的事情

Note : You need to make little adjusts in the code bellow according to your need. 注意 :您需要根据需要在下面的代码中进行少量调整。

//find header
WebElement header = findElement(By.xpath("//div[starts-with(.,'Specification Status')]"));

//Make mouse event hover on header for show the arrow
Actions action = new Actions(driver);
action.moveToElement(header).perform();

//click on arrow
header.findElement(By.cssSelector(".x-column-header-trigger")).click();

//Mouse over event on filter item, this element not linked on header
// findelement no DOM.
WebElement filtros = findElement(By.cssSelector("a[aria-label='Filters'"));
action.moveToElement(filtros).perform();

//find inputs, this element not linked to header
List<WebElement> searchFields = findElements(By.cssSelector("input[placeholder='Enter Filter Text...']"));

WebElement searchId = searchFields.get(0); //<<< here is according how many inputs is showed in your filters
action.moveToElement(searchId).perform();
searchId.sendKeys("Value to search");

Thread.sleep(1500);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM