I have a page that has search results that may come up with a bunch of results depending on the name used, I’d like to be able to select the specific one I want (even though i’ll likely use both first and last names removing the need, i’d like the option).
Code for the search results table:
<!-- ngIf: searchResults.customers && searchResults.customers.length > 0 --><div class="col-sm-4 ng-scope" ng-if="searchResults.customers && searchResults.customers.length > 0">
<div class="panel panel-default animated fadeIn">
<div class="panel-heading">
<h4><i class="fa fa-users"></i> Contacts</h4>
</div>
<!-- List group -->
<div class="list-group">
<!-- ngRepeat: foundCustomer in searchResults.customers --><a href="javascript:void(0)" class="list-group-item ng-scope" ng-repeat="foundCustomer in searchResults.customers" ng-click="customerClicked(foundCustomer)">
<h4 class="list-group-item-heading ng-binding">
<!-- ngIf: ::foundCustomer.is_cip_user --> Princess
Belle
</h4>
<p class="list-group-item-text ng-binding">555-555-5555</p>
<!-- ngIf: foundCustomer.company_name --><p class="list-group-item-text ng-binding ng-scope" ng-if="foundCustomer.company_name">
Disney<br>
</p><!-- end ngIf: foundCustomer.company_name -->
</a><!-- end ngRepeat: foundCustomer in searchResults.customers --><a href="javascript:void(0)" class="list-group-item ng-scope" ng-repeat="foundCustomer in searchResults.customers" ng-click="customerClicked(foundCustomer)">
<h4 class="list-group-item-heading ng-binding">
<!-- ngIf: ::foundCustomer.is_cip_user --> Princess
Jasmine
</h4>
<p class="list-group-item-text ng-binding">555-555-5555</p>
<!-- ngIf: foundCustomer.company_name --><p class="list-group-item-text ng-binding ng-scope" ng-if="foundCustomer.company_name">
Disney<br>
</p><!-- end ngIf: foundCustomer.company_name -->
</a><!-- end ngRepeat: foundCustomer in searchResults.customers --><a href="javascript:void(0)" class="list-group-item ng-scope" ng-repeat="foundCustomer in searchResults.customers" ng-click="customerClicked(foundCustomer)">
<h4 class="list-group-item-heading ng-binding">
<!-- ngIf: ::foundCustomer.is_cip_user --> Princess
Leia
</h4>
<p class="list-group-item-text ng-binding">555-555-5555</p>
<!-- ngIf: foundCustomer.company_name --><p class="list-group-item-text ng-binding ng-scope" ng-if="foundCustomer.company_name">
Disney<br>
</p><!-- end ngIf: foundCustomer.company_name -->
</a><!-- end ngRepeat: foundCustomer in searchResults.customers -->
</div>
</div>
</div><!-- end ngIf: searchResults.customers && searchResults.customers.length > 0 -->
<!-- ngIf: searchResults.vehicles && searchResults.vehicles.length > 0 -->
<!-- ngIf: searchResults.vehicles && searchResults.vehicles.length == 0 && searchResults.customers && searchResults.customers.length == 0 && searchResults.businesses && searchResults.businesses.length == 0 -->
</div>
I’d like to select based on their name in this case. Currently it is hard coded to just choose which option i want which prevents me from also being able to validate the chosen person is the correct person.
Here is what the table looks like on site:
Here is the code in Katalon when just selecting an option outright:
WebUI.click(findTestObject(‘Object Repository/Page_SOMETHING/Page_SOMETHING - Service/h4_Tom’))
Here is code I wrote today to load in my data (which works) and it performs the search, but i can’t find a way to point to the name in the results…
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
TestData searchData = findTestData(‘Data Files/WO_Object_Search’)
firstName = searchData.internallyGetValue(‘firstName’, 1)
lastName = searchData.internallyGetValue(‘lastName’, 1)
searchResults = ’ ‘+firstName+’ ‘+lastName+’ ’
WebUI.openBrowser(‘’)
WebUI.navigateToUrl(‘https://something.com/login’)
WebUI.setText(findTestObject(‘Page_SOMETHING/input_Sorry something went wro’), ‘something@gmail.com’)
WebUI.setEncryptedText(findTestObject(‘Object Repository/Page_SOMETHING/Page_SOMETHING/input_Sorry something went wro_13’), ‘apassword’)
WebUI.click(findTestObject(‘Object Repository/Page_SOMETHING/Page_SOMETHING/input_Sorry something went wro_14’))
WebUI.click(findTestObject(‘Object Repository/Page_SOMETHING/Page_SOMETHING - Service/div_concat(id( beamerOverlay’))
for (def index : (0…searchData.getRowNumbers() - 1)) {
firstName = searchData.internallyGetValue(‘firstName’, index)
lastName = searchData.internallyGetValue('lastName', index)
searchResults = ' '+firstName+' '+lastName+' '
WebUI.click(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/a_New'))
WebUI.setText(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/input_HERE_job-wizard-search-b'),
(firstName + ' ') + lastName)
WebUI.verifyElementAttributeValue(findTestObject('woResults', [('#text') : searchResults]))
WebUI.click(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/h4_Impossible Grandam'))
WebUI.setText(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/textarea_Overview_form-control'),
'Overview box')
WebUI.click(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/label'))
WebUI.setText(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/input_Hours hours_variable'), '6700')
WebUI.selectOptionByValue(findTestObject('Page_SOMETHING/Page_SOMETHING - Service/select_Select a Turtle'), 'object:530',
true)
WebUI.setText(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/input_Stuff'),
'2')
WebUI.click(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/label_Credit'))
WebUI.click(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/label_Text'))
WebUI.click(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/input_Phone_btn btn-success bt'))
WebUI.click(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/button_Close'))
WebUI.click(findTestObject('Object Repository/Page_SOMETHING/Page_SOMETHING - Service/a_StuffAgain'))
}
WebUI.closeBrowser()
Note I was using a name with Tom earlier hence that showing instead of a princess. Yes i will validate with first and last name, but again I want the results to show more than one currently while selecting the correct one (it will have access to the last name field in the data spreadsheet). Also, altered some name stuff but that is just for work reasons.
This is more so I can understand how to scan the results and what to use to find the result i want to click.
Thanks.