Katalon Studio v5.8 - It's time for the all-new API testing experience
Els Van Och
Katalon Apprentice
11/17/2017

enter data in select2-selection

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(. | //[@haspopup = 'true']) = count(//[@haspopup = 'true'])][count(. | //[@expanded = 'true']) = count(//[@expanded = 'true'])][count(. | //[@tabindex = '0']) = count(//[@tabindex = '0'])][count(. | //[@labelledby = 'select2-volunteers_volunteer_nationality-container']) = count(//[@labelledby = 'select2-volunteers_volunteer_nationality-container'])][count(. | //[@owns = 'select2-volunteers_volunteer_nationality-results']) = count(//[@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

Upvote
Quote

Comments

  • Els Van Och
    Katalon Apprentice
    11/29/2017

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

    Upvote
    Quote
  • Francisco Mancardi
    Katalon Apprentice
    05/16/2018
    Please can you be kinldy enough to share your findings? or anyone @ Katalon can provide the info?
    Upvote
    Quote
  • chiraz
    Katalon Apprentice
    10/09/2018

    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
    Upvote
    Quote
Sign In or Register to comment.