我是 Protractor E2E 測試的新手。在我正在測試的網頁上,有兩個類名為name-part. 我需要一種方法將兩者的值連接到一個元素結果中。這是代碼的布局方式。<div class="offer-name"> 1.01 ct. Center Diamond <span class="name-part">Monique Lhuillier Timeless Rollover Halo Diamond Engagement Ring</span> <span class="name-part">in 18k Rose Gold</span></div>我需要將兩個跨度連接成一個斷言。Monique Lhuillier Timeless Rollover Halo Diamond Engagement Ring in 18k Rose Gold這是我的代碼:tester.it('Clicking the defined number of products should bring up Product Details page every time', (testContext) => {catalogResults().totalResults().then((totalCount) => { for (let i = 0; i < totalCount; i++) { let testLink = element.all(by.css('.catalog-offer a')).get(i); const offerResultsName = element.all(by.css('.offer-name')).get(i).getText(); const offerResultsPrice = element.all(by.css('.offer-details-wrapper .price-display')).get(i).getText(); testerUtils.performActionAndWait(testLink.click); element(by.css('.image-and-details .name-start')).getText().then(displayName => { expect(offerResultsName).to.eventually.include(displayName, 'Display name does not match with results name.') console.log(displayName); }) element(by.css('.details .subtotal > span')).getText().then(displayPrice => { expect(offerResultsPrice).to.eventually.equal(displayPrice, 'Display price does not match with results price.'); console.log(displayPrice); }); expect(testerUtils.getPageId()).to.eventually.equal('Recently Purchased Engagement Ring Details'); testerUtils.go(testContext.url); }});});
量角器連接兩個具有相同類名的跨度
至尊寶的傳說
2023-03-24 16:40:02