How to verify that ads sorted from high to low prices

**hello there please I need an urgent help **
I need to verify when sorting ADS from high to low price drop-down list the results will display ads sorted by price from high to low this is my code but I don’t know how to do the verification step can anybody help me, please

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
import org.openqa.selenium.Keys as Keys

WebUI.openBrowser(‘’)

WebUI.navigateToUrl(‘https://staging.tajercom.com/’)

WebUI.click(findTestObject(‘Sort Ads by High to Low _OR 5/Page_tajercom Tajercom/state_dropdown’))

WebUI.click(findTestObject(‘Sort Ads by High to Low OR 5/Page_tajercom Tajercom/amman (1)’))

WebUI.waitForElementVisible(findTestObject(‘Sort Ads by High to Low OR 5/Page_tajercom Tajercom/select’), 5)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Sort Ads by High to Low OR 5/Page_tajercom Tajercom/select’),
‘1978’, true)

WebUI.click(findTestObject(‘Sort Ads by High to Low OR 5/Page_tajercom Tajercom/sort _dropdown’))

WebUI.click(findTestObject(‘Sort Ads by High to Low OR 5/Page_tajercom Tajercom/high to low sort’))

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Sort Ads by High to Low OR 5/Page_tajercom Tajercom/select (1)’),
‘desc’, true)

WebUI.verifyElementPresent(findTestObject(‘Sort Ads by High to Low _OR 5/Page_tajercom Tajercom/ad_price12000’), 6)

WebUI.verifyElementPresent(findTestObject(‘Sort Ads by High to Low _OR 5/Page_tajercom Tajercom/ad_price50’), 6)

and here a screenshot from the web page im trying to test

thanks in advance

Can you share the HTML for one of the prices, and maybe some of it’s parent elements? If I had that, then I would approach it with something like:

WebDriver driver = DriverFactory.getWebDriver()
List<WebElement> prices = driver.findElements(By.xpath("path/to/price/elements"))
for(int i = 1; i < prices.size(); i++) {
    BigDecimal currentPrice = new BigDecimal(prices.get(i).getText())
    BigDecimal previousPrice = new BigDecimal(prices.get(i - 1).getText())
    assert currentPrice.compareTo(previousPrice) == -1
}

What this code does is collect a list of all the prices on the page (this is what we need the HTML code for), then iterate through the list and assert that each price in the list is less than the previous price.

thank you for your response here a screenshot of the HTML for one of the prices

please
@Brandon_Hein can you more explain how ?

Can you test this xpath for me?

//strong[@class='num' and ./span[@class='currency-jd']]

The easiest way to test this is:

1.) In your inspector, open the “Console” tab.
2.) While sitting on the page you want to get prices from, enter the xpath into the console like this:

$x("//strong[@class='num' and ./span[@class='currency-jd']]")

You should see a number of results returned. Hopefully, you get the same number of results as there are prices on the page. Please let me know your results.