我无法获得正确的元素

I can't get right elements

我单击排序按钮,获取所有价格,我需要确保元素按价格正确排序。所以我需要获取 price value="377", price value="1288", price value="1688" 等,但我无法获取正确的元素。

<div class="ssl-price-box">
    <price value="377" units="/yr" class="lg-price ng-isolate-scope">
        <span class="price">
            <span class="currency-icon">$</span>
            <span class="integer ng-binding">3.</span>
            <span class="cent ng-binding">77</span>
            <span class="units">/yr</span>
        </span>
    </price>
    <!-- ngIf: product.prices.max.certIsPromo -->
</div>
<div class="ssl-content">
    <div class="ssl-price-box">
        <price value="1288" units="/yr" class="lg-price ng-isolate-scope">
            <span class="price">
                <span class="currency-icon">$</span>
                <span class="integer ng-binding">12.</span>
                <span class="cent ng-binding">88</span>
                <span class="units">/yr</span>
            </span>
        </price>

我尝试搜索 css、className、xpath、repearet,我想如果它们都是相同的 repeater 就可以了。 我的代码:

const allSSLList = $$('.ssl-price-box');
const newAllSSLList = allSSLList.sort((a, b)=>a-b));

expect(await allSSLList).toBe(massiveOfElements)

我只需要获取价格,例如“3.77”、“12.88”、“16.88”等,然后验证它们是否按 ASC 排序,但我得到了所有价格,甚至是旧价格。我只需要得到 where

<span class="price">
    <price value="377" units="/yr" class="lg-price ng-isolate-scope">

预计 ['$3.77/YR', '$12.88/YR $26.99/YR', '$16.88/YR $31.99/YR', '$19.66/YR $35.88/YR', '$30.88/YR $44.99/YR', ' $38.88/YR $95.99/YR', '$59.99/YR', '$68.88/YR $138.99/YR', '$70.88/YR $96.99/YR', '$78.19/YR', '$78.19/YR', '$134.99/YR', '$1​​38.88/YR $215.89/YR'] 为 'smth'。 堆栈:

从所提供的 HTML 看来,CSS 选择器 div.ssl-price-box > price 会为您提供所需的所有价格元素。从那里,您可以使用 .getAttribute() to pull the value attribute from each element as "377", "1288", etc. Then you would want to , copy that array, sort the second array, and then 来验证这两个列表是否已排序。