Hello All,
I would like to select autocomplete suggested value whenever I send the keys to that field.
Please refer the attached screen shots for source code and error messages
Test:
- Open url
- When sending keys “AUSY”, Autocomplete field suggesting some list (ex: AUSY_FR, AUSY_TEST2, AUSY_TEST3, AUSY_RECETTE, AUSY).
- In the list, I want to click AUSY to select the right value
- To do that I’ve created a keyword like below
@Keyword
def selectAutocompleteValue(String ele_xpath, String texttoSelect){
WebDriver driver =DriverFactory.getWebDriver()
List dropdown_menu=driver.findElements(By.xpath(ele_xpath))
for(WebElement element:dropdown_menu){
String innerhtml=element.getAttribute("innerHTML")
if(innerhtml.equalsIgnoreCase(texttoSelect)){
element.click()
break;
}
System.out.println("Values from autocomplete fields is =======" +innerhtml)
}
}
Then I wrote the below test code, to send the keys on that field.
WebUI.sendKeys(findTestObject(‘Object Repository/Page_User_Mgmt/Step1_CreateUser_Info/txt_OrganizationName’), GlobalVariable.G_Create_User_NonOEM, FailureHandling.STOP_ON_FAILURE)
WebUI.delay(1)
CustomKeywords.‘com.sgds.util.WebDriverHelper.selectAutocompleteValue’(“.//a[@class=‘ui-corner-all’]”, ‘AUSY’ )
WebUI.delay(1)
But, I’m getting the below errors.
12-18-2018 10:43:08 AM - [START] - Start action : com.sgds.util.WebDriverHelper.selectAutocompleteValue
Values from autocomplete fields is =======AUSY_FR
Values from autocomplete fields is =======AUSY_TEST2
Values from autocomplete fields is =======AUSY_TEST3
Values from autocomplete fields is =======AUSY_RECETTE
****JavaScript error: https://recette.sgds/sgds/sgdsPortalTheme/static/js/opensource/jquery-ui-1.8.22.custom.min.js, line 45: TypeError: d.item is undefined
1545126188369 Marionette DEBUG [2147483649] Canceled page load listener because no navigation has been detected
12-18-2018 10:43:08 AM - [PASSED] - com.sgds.util.WebDriverHelper.selectAutocompleteValue is PASSED
12-18-2018 10:43:08 AM - [END] - End action : com.sgds.util.WebDriverHelper.selectAutocompleteValue
Conclusion:
I’m not able to perform the action what I want. The application just showing the list. So next step got failed with the below message:
Unable to select option by label ‘Mr.’ of object ‘Object Repository/Page_User_Mgmt/Step1_CreateUser_Info/drpDown_Title’ (Root cause: org.openqa.selenium.ElementClickInterceptedException: Element