Not able pick a value from a drop down list

Hi,
I was trying to select a value from drop down list with help of selectOptionByIndex method but it was not successful.It is not also clicking that element with simple WebUI.Click method.
I tried different options but all in Vain.could you please help me on this .
Screenshot attached.
katalon unable to capture the list of values available in the list.Only it capture the parent element(Location).
The attribute of the element is //*[@name = ‘pt1:contentAreaReg:0:tabrg1:2:soc1’ and @id = ‘pt1:contentAreaReg:0:tabrg1:2:soc1::content’].
image

selectOptionByIndex will only work if the element is a <select> element.

My guess is that you are working with some kind of <input> element here. Please share the HTML for the dropdown and surrounding elements so that we can provide a solution.

image
Not able to capture the elements present in the drop down list

Being so selective about what you’re choosing to reveal about the HTML is not helpful to us. If you really expect us to help, show all of that HTML

From looking at your image, I suspect some tinkering with the styles to reveal a (perhaps) hidden select element.

Please, make a clear statement about what you want to achieve and show the elements you expect to be targeted by the test code.

As Russ mentioned, we need to see all of the elements involved. In general, it’s useful to see at least:

1.) The target element,
2.) the parent or first few ancestors of the element, and
3.) all children or first few descendants of the target element.

Thanks

I can see that this is probably an Outsystem web application. Sometimes u need to create the xpath manualy.

Note that you need to do like //parent[]/child/child/select[@name]. Because the way you do some times it may exist more then one select object with the same @name attribut

[HTML Code for location field…

Sorry, this is not the HTML code. you had it right in your previous post, we just need to see more elements.

This is all the elements available in the below window.
image

The HTML codes for all the elements attached herewith.Cretae PO elements.txt (1.9 KB)

Sorry, you’re really not getting me. I think you are confused by what an element is. For the purposes of this discussion, an element is anything in the HTML code that starts with “<” and ends with “>”.

What you are asking about is specifically the “Location” field, and how to select an option from the drop-down associated with that field. This drop-down is represented by the <select> element that you’ve shared in this screenshot:

image

What we need to see in addition to this <select> element is:

1.) The parent of this element:

image

2.) The children of this element. Click the arrow to expand the element and view the children:

image

1 Like

Cretae PO elements-1.txt (497 Bytes)

Hi ,
If you check the previous file i have already attached parent and child element in a single line.
Anyway i am adding in a separate file in HTML format .Hope this is the details you want.
plz check this.

Any suggestion?

I did face an problem like this. And my solution was to go back to its parent

  • Solution 1: //parent//child/child/child/child/select etc. this worked for me.

  • Solution 2: I needed to first click its arrow first and then select the value.

  • Solution 3: the fastest way is to create a custom keyword.

Test in Chrome console if you xpath is correct etc.

Try this:

WebDriver driver = DriverFactory.getWebDriver()
WebElement element = findElement(By.xpath("//label[text()='Location']/preceding-sibling::select"))
Select select = new Select(element)
select.selectByIndex(5)

If that doesn’t work, then from looking at the HTML, I suspect you are working with a React front end, in which case we may need to do some clever clicking.