Using script to click drop down in Joomla 3.x

Joomla uses bootstrap to display dropdown boxes. this means that the actual element is a a uniform list that is clicked on and the select box is a hidden element I assume with a javascript event against it.

Published
  • - Select Status -
  • Published
  • Unpublished
  • Archived
  • Trashed
  • All

The element is below the visible part of the screen - that is you have to scroll the screen up to see it. So when I try to click on it it can’t be found.

I’ve been trying to use selectOptionByIndex to click the element with no success. I got the xpath via the code inspector in Chrome.Any help would be great.

This is the script I’ve been trying

WebUI.maximizeWindow()

WebUI.click(findTestObject(‘Object Repository/Page_Activities/b’))

WebUI.selectOptionByIndex((‘//*[@id=“filter_published”]/option[5]’))

Hi Alan

The element is below the visible part of the screen - that is you have
to scroll the screen up to see it. So when I try to click on it it
can’t be found.

Does this help?

https://docs.katalon.com/display/KD/[WebUI]+Scroll+To+Element

Hi Russ,

thanks for the suggestion but it doesn’t seem to work. It won’t scroll to the drop down.

I used

WebUI.maximizeWindow()

WebUI.scrollToElement(findTestObject(’//*[@id=“filter_published_chzn”]’)/a/span)

WebUI.click(findTestObject(‘Page_Activities/b (1)’))

WebUI.click(findTestObject(‘Page_Activities/li_Trashed (1)’))

I got the @id filter from the element inspector. I also tried it using the

WebUI.maximizeWindow()

WebUI.scrollToElement(findTestObject(‘Page_Activities/b (1)’))

WebUI.click(findTestObject(‘Page_Activities/b (1)’))

WebUI.click(findTestObject(‘Page_Activities/li_Trashed (1)’))

but neither made it scroll to the elemet

Forget the select element/options elements - they’re set to css display:none, meaning they’re not accessible by WebUI.selectOptionBy* APIs.

BTW, you cannot pass an xpath expression directly to findTestObject, but that’s not really the issue here.

You need to deal with the UL/LI construct directly using WebUI.click(). It’s not clear from the HTML you posted, which element will make the element “drop down”. Find it using the devtools and create a TestObject for it (if you haven’t already). Then you can issue a click on it (after you have scrolled to it if necessary).

Once you have the list opened up, then you can target the relevant LI element with another WebUI.click()

Hang in there. This is going to work.

Let me know how it goes.

Hi Russ

got it working - thanks for the support :slight_smile: