Find Element from a Class

Hello! I am a little new with Katalon but here is my problem:

I have a webpage that shows two elements from the same class: one for the country and another from the country data currency. Both elements are drop down bars. So then I got a lot of countrys in the first one and I am not able to select any of the countrys ¿How can I solve it?

The element:

<div class="dropdown" data-control="SelectedCountries">
	<select aria-label="Change your shipping country" id="gle_selectedCountry" onchange="GlobalE.shippingSwitcher.OnCountryChanged(this)" tabindex="0"> ==$0
		<option data-culturecode data-currency="80" data-currency-fixed="false" data-geoperated="true" data-isredirect"false" data-redirecturl value="AL">Albania</option>

¿How would you select Albania(for example) on the list with Katalon/Selenium?

Can you show us any HTML of the elements? It sounds like you may not have the correct pathway to the “countrys” dropdown list.

Edit: Do you have the xpath to the “Shipping Country” as below?

id("gle_selectedCountry")

or

//select[@id="gle_selectedCountry"]    or   //*[@id="gle_selectedCountry"] 

Edit2: If you have other attributes in the element’s list of values, remove the checkmark from them, except for “tag” and “xpath”.

If you have the xpath to your “shipping country” correct, then you should be able to use the below:
If using Katalon Studio statements:

WebUI.selectOptionByValue(findTestObject('...'), 'AL')

Alternatively, you could use:

WebUI.selectOptionByLabel(findTestObject('...'), 'Albania')

or, using Selenium:

Select select = new Select(driver.findElement(By.id("gle_selectedCountry")));
select.selectByVisibleText('Albania');

And if you don’t use the Object Repository, then you can use:

import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.testobject.ConditionType as ConditionType
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

xpath = 'id("gle_selectedCountry")'
TestObject myItem = new TestObject(xpath)
myItem.addProperty("xpath", ConditionType.EQUALS, xpath )

WebUI.selectOptionByValue(myItem , 'AL')
1 Like