enter data in select2-selection


#1

Dear,

I’m trying to enter data in a select2-selection but I can’t get it to work. I have been searching for others with the same problem en from that I got this code:
import org.openqa.selenium.WebDriver
import org.openqa.selenium.support.ui.Select

import org.openqa.selenium.StaleElementReferenceException
import org.openqa.selenium.WebElement
import org.openqa.selenium.support.ui.Select

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

try {
WebUI.selectOptionByValue(findTestObject(‘registration/Page_Staging/span_select2-selection select2’), ‘registration/Page_Staging/li_Belgian’, true)
}
catch (StaleElementReferenceException e) {
TestObject to = findTestObject(‘registration/Page_Staging/span_select2-selection select2’)
WebElement webElement = WebUiCommonHelper.findWebElement(to)
new Select(WebUiCommonHelper.findWebElement(findTestObject(‘registration/Page_Staging/span_select2-selection select2’), 2)).selectByValue(“Belgian”)

WebUI.waitForPageLoad(30)
}

But the dropbox doesn’t get filled. I have this errormessage:

Test Cases/registration collaborator FAILED because (of) Unable to select option by value ‘registration/Page_Staging/li_Belgian’ of object ‘Object Repository/registration/Page_Staging/span_select2-selection select2’ using regular expression (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/registration/Page_Staging/span_select2-selection select2’ located by ‘By.xpath: //span[count(. | //[@class = ‘select2-selection select2-selection–single’]) = count(//[@class = ‘select2-selection select2-selection–single’])][count(. | //[@role = ‘combobox’]) = count(//[@role = ‘combobox’])][count(. | //[@aria-haspopup = ‘true’]) = count(//[@aria-haspopup = ‘true’])][count(. | //[@aria-expanded = ‘true’]) = count(//[@aria-expanded = ‘true’])][count(. | //[@tabindex = ‘0’]) = count(//[@tabindex = ‘0’])][count(. | //[@aria-labelledby = ‘select2-volunteers_volunteer_nationality-container’]) = count(//[@aria-labelledby = ‘select2-volunteers_volunteer_nationality-container’])][count(. | //[@aria-owns = ‘select2-volunteers_volunteer_nationality-results’]) = count(//[@aria-owns = ‘select2-volunteers_volunteer_nationality-results’])][count(. | //[@id=“edit_volunteers_volunteer_1458”]/div[1]/div[1]/div[2]/div[2]/span/span[1]/span) = count(//[@id=“edit_volunteers_volunteer_1458”]/div[1]/div[1]/div[2]/div[2]/span/span[1]/span)]’ not found)

I inspected the page and copied the path into the xpath.

Can you advise on how to solve this. I have more dropdowns of the same type.

regards
Els


#2

I solved it by adjusting the settings of the select2 field in the repository, thanks to Oliver of the Katalon support team


#3

Please can you be kinldy enough to share your findings? or anyone @ Katalon can provide the info?


#4

Els Van Och said:

I solved it by adjusting the settings of the select2 field in the repository, thanks to Oliver of the Katalon support team

please can you give me more details ? Thank you


#5

Could you please share the the changes which you updated in OR for it?


#6

@Ankesh

I’d really like to close this thread so please post your question in a new topic. This thread is old and the original post was written by somebody that has not returned since 11/2017.

When you re-ask your question, be sure to include as much information as possible. Follow the advice here:


#7