Gabriel Robaina
Gabriel Robaina

Reputation: 741

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).

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...

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. 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).

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?

Ext JS column header menu

Upvotes: 1

Views: 197

Answers (2)

Roberto Pegoraro
Roberto Pegoraro

Reputation: 1497

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);

Upvotes: 0

Gabriel Robaina
Gabriel Robaina

Reputation: 741

Thanks @JimGrigoryan for the advice! 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. Now it does not matter the dynamic IDs Ext Js gives to the elements.

Upvotes: 0

Related Questions